From 45e1b001e3c0687b9f8b035652d2f02aba692d6f Mon Sep 17 00:00:00 2001 From: dbuechel Date: Wed, 8 Jan 2020 09:55:23 +0100 Subject: [PATCH] SEBWIN-302: Implemented configuration for browser window toolbar. --- .../DataMapping/BrowserDataMapper.cs | 12 ++++++++++++ .../ConfigurationData/Keys.cs | 1 + SafeExamBrowser.Settings/Browser/WindowSettings.cs | 5 +++++ .../BrowserWindow.xaml | 2 +- .../BrowserWindow.xaml.cs | 6 ++++++ .../BrowserWindow.xaml | 2 +- .../BrowserWindow.xaml.cs | 6 ++++++ 7 files changed, 32 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs index 30619f16..c16f3536 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs @@ -93,6 +93,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping case Keys.Browser.QuitUrlConfirmation: MapQuitUrlConfirmation(settings, value); break; + case Keys.Browser.ShowToolbar: + MapShowToolbar(settings, value); + break; case Keys.Browser.StartUrl: MapStartUrl(settings, value); break; @@ -263,6 +266,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping } } + private void MapShowToolbar(AppSettings settings, object value) + { + if (value is bool show) + { + settings.Browser.AdditionalWindow.ShowToolbar = show; + settings.Browser.MainWindow.ShowToolbar = show; + } + } + private void MapStartUrl(AppSettings settings, object value) { if (value is string url) diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs index 08de422c..24f307e7 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs @@ -51,6 +51,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData internal const string PopupBlockForeignHost = "newBrowserWindowByLinkBlockForeign"; internal const string QuitUrl = "quitURL"; internal const string QuitUrlConfirmation = "quitURLConfirm"; + internal const string ShowToolbar = "enableBrowserWindowToolbar"; internal const string StartUrl = "startURL"; internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode"; internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode"; diff --git a/SafeExamBrowser.Settings/Browser/WindowSettings.cs b/SafeExamBrowser.Settings/Browser/WindowSettings.cs index fdd2ead9..60f89d35 100644 --- a/SafeExamBrowser.Settings/Browser/WindowSettings.cs +++ b/SafeExamBrowser.Settings/Browser/WindowSettings.cs @@ -75,5 +75,10 @@ namespace SafeExamBrowser.Settings.Browser /// Determines whether the user will need to confirm every reload attempt. /// public bool ShowReloadWarning { get; set; } + + /// + /// Determines whether the window toolbar is visible. + /// + public bool ShowToolbar { get; set; } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml index 358ef9e0..82642240 100644 --- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml @@ -42,7 +42,7 @@ - + diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs index 2dc61875..3376dcfa 100644 --- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs @@ -253,10 +253,16 @@ namespace SafeExamBrowser.UserInterface.Desktop ForwardButton.IsEnabled = WindowSettings.AllowForwardNavigation; ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed; + MenuButton.IsEnabled = settings.AllowPageZoom || WindowSettings.AllowDeveloperConsole; + ReloadButton.IsEnabled = WindowSettings.AllowReloading; ReloadButton.Visibility = WindowSettings.AllowReloading ? Visibility.Visible : Visibility.Collapsed; + Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed; + UrlTextBox.Visibility = WindowSettings.AllowAddressBar ? Visibility.Visible : Visibility.Hidden; + + ZoomMenuItem.Visibility = settings.AllowPageZoom ? Visibility.Visible : Visibility.Collapsed; } private void InitializeBounds() diff --git a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml index 32fd7dcf..b28a7a57 100644 --- a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml +++ b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml @@ -42,7 +42,7 @@ - + diff --git a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs index 0b76c024..27d8674e 100644 --- a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs @@ -253,11 +253,17 @@ namespace SafeExamBrowser.UserInterface.Mobile ForwardButton.IsEnabled = WindowSettings.AllowForwardNavigation; ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed; + MenuButton.IsEnabled = settings.AllowPageZoom || WindowSettings.AllowDeveloperConsole; + ReloadButton.IsEnabled = WindowSettings.AllowReloading; ReloadButton.Visibility = WindowSettings.AllowReloading ? Visibility.Visible : Visibility.Collapsed; + Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed; + UrlTextBox.Visibility = WindowSettings.AllowAddressBar ? Visibility.Visible : Visibility.Hidden; + ZoomMenuItem.Visibility = settings.AllowPageZoom ? Visibility.Visible : Visibility.Collapsed; + if (!WindowSettings.AllowAddressBar) { BackwardButton.Height = 35;