From 8908efc93e9ea5b48cc0020ffa70e82f3ed2ad94 Mon Sep 17 00:00:00 2001 From: Jan Philipp Weber <10946850+jp-weber@users.noreply.github.com> Date: Fri, 18 Sep 2020 19:22:24 +0200 Subject: [PATCH] - mobile UI adapted --- .../Windows/FileSystemDialog.xaml.cs | 4 ++-- .../Windows/FileSystemDialog.xaml.cs | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/FileSystemDialog.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Windows/FileSystemDialog.xaml.cs index ed34b488..a43095b5 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/FileSystemDialog.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/FileSystemDialog.xaml.cs @@ -289,12 +289,12 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows InitializeFileSystem(); } - private DriveInfo[] GetDrives(bool showAll = false) + private DriveInfo[] GetDrives() { var drives = DriveInfo.GetDrives(); int noDrives = (int)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0); - if (noDrives > 0 && !showAll) + if (noDrives > 0) { return drives.Where(drive => (noDrives & (int)(Math.Pow(2, (int)(drive.RootDirectory.ToString()[0]) - 65))) == 0).ToArray(); } diff --git a/SafeExamBrowser.UserInterface.Mobile/Windows/FileSystemDialog.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Windows/FileSystemDialog.xaml.cs index f6796540..e039c06e 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Windows/FileSystemDialog.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Windows/FileSystemDialog.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using FontAwesome.WPF; +using Microsoft.Win32; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.UserInterface.Contracts.FileSystemDialog; using SafeExamBrowser.UserInterface.Contracts.Windows; @@ -288,6 +289,20 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows InitializeFileSystem(); } + private DriveInfo[] GetDrives() + { + var drives = DriveInfo.GetDrives(); + int noDrives = (int)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0); + + if (noDrives > 0) + { + return drives.Where(drive => (noDrives & (int)(Math.Pow(2, (int)(drive.RootDirectory.ToString()[0]) - 65))) == 0).ToArray(); + } + + return drives; + } + + private void InitializeFileSystem() { if (restrictNavigation && !string.IsNullOrEmpty(initialPath)) @@ -318,7 +333,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows private void InitializeUnrestricted() { - foreach (var drive in DriveInfo.GetDrives()) + foreach (var drive in GetDrives()) { FileSystem.Items.Add(CreateItem(drive.RootDirectory)); }