diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs
index dd058be4..1917424e 100644
--- a/SafeExamBrowser.Browser/BrowserApplicationController.cs
+++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs
@@ -95,13 +95,13 @@ namespace SafeExamBrowser.Browser
logger.Info("Terminated browser.");
}
- private void CreateNewInstance(BrowserSettings custom = null)
+ private void CreateNewInstance(string url = null)
{
var id = new BrowserInstanceIdentifier(++instanceIdCounter);
var isMainInstance = instances.Count == 0;
var instanceLogger = logger.CloneFor($"BrowserInstance {id}");
- var instanceSettings = custom ?? settings;
- var instance = new BrowserApplicationInstance(appConfig, instanceSettings, id, isMainInstance, messageBox, instanceLogger, text, uiFactory);
+ var startUrl = url ?? settings.StartUrl;
+ var instance = new BrowserApplicationInstance(appConfig, settings, id, isMainInstance, messageBox, instanceLogger, text, uiFactory, startUrl);
instance.Initialize();
instance.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
@@ -149,24 +149,8 @@ namespace SafeExamBrowser.Browser
private void Instance_PopupRequested(PopupRequestedEventArgs args)
{
- // TODO: Use settings for additional browser windows!
- var popupSettings = new BrowserSettings
- {
- AllowAddressBar = false,
- AllowBackwardNavigation = false,
- AllowConfigurationDownloads = settings.AllowConfigurationDownloads,
- AllowDeveloperConsole = settings.AllowDeveloperConsole,
- AllowDownloads = settings.AllowDownloads,
- AllowForwardNavigation = false,
- AllowPageZoom = settings.AllowPageZoom,
- AllowPopups = settings.AllowPopups,
- AllowReloading = settings.AllowReloading,
- ShowReloadWarning = settings.ShowReloadWarning,
- StartUrl = args.Url
- };
-
logger.Info($"Received request to create new instance for '{args.Url}'...");
- CreateNewInstance(popupSettings);
+ CreateNewInstance(args.Url);
}
private void Instance_Terminated(InstanceIdentifier id)
diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
index 42d00d6d..f6be129c 100644
--- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
+++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
@@ -33,6 +33,12 @@ namespace SafeExamBrowser.Browser
private BrowserSettings settings;
private IText text;
private IUserInterfaceFactory uiFactory;
+ private string url;
+
+ private BrowserWindowSettings WindowSettings
+ {
+ get { return isMainInstance ? settings.MainWindowSettings : settings.AdditionalWindowSettings; }
+ }
public InstanceIdentifier Id { get; private set; }
public string Name { get; private set; }
@@ -52,7 +58,8 @@ namespace SafeExamBrowser.Browser
IMessageBox messageBox,
IModuleLogger logger,
IText text,
- IUserInterfaceFactory uiFactory)
+ IUserInterfaceFactory uiFactory,
+ string url)
{
this.appConfig = appConfig;
this.Id = id;
@@ -62,6 +69,7 @@ namespace SafeExamBrowser.Browser
this.settings = settings;
this.text = text;
this.uiFactory = uiFactory;
+ this.url = url;
}
internal void Initialize()
@@ -82,7 +90,7 @@ namespace SafeExamBrowser.Browser
keyboardHandler.ZoomResetRequested += ZoomResetRequested;
lifeSpanHandler.PopupRequested += LifeSpanHandler_PopupRequested;
- control = new BrowserControl(contextMenuHandler, displayHandler, downloadHandler, keyboardHandler, lifeSpanHandler, requestHandler, settings.StartUrl);
+ control = new BrowserControl(contextMenuHandler, displayHandler, downloadHandler, keyboardHandler, lifeSpanHandler, requestHandler, url);
control.AddressChanged += Control_AddressChanged;
control.LoadingStateChanged += Control_LoadingStateChanged;
control.TitleChanged += Control_TitleChanged;
@@ -90,8 +98,7 @@ namespace SafeExamBrowser.Browser
logger.Debug("Initialized browser control.");
- window = uiFactory.CreateBrowserWindow(control, settings);
- window.IsMainWindow = isMainInstance;
+ window = uiFactory.CreateBrowserWindow(control, settings, isMainInstance);
window.Closing += () => Terminated?.Invoke(Id);
window.AddressChanged += Window_AddressChanged;
window.ReloadRequested += ReloadRequested;
@@ -112,6 +119,8 @@ namespace SafeExamBrowser.Browser
private void Control_LoadingStateChanged(bool isLoading)
{
+ window.CanNavigateBackwards = WindowSettings.AllowBackwardNavigation && control.CanNavigateBackwards;
+ window.CanNavigateForwards = WindowSettings.AllowForwardNavigation && control.CanNavigateForwards;
window.UpdateLoadingState(isLoading);
}
@@ -158,7 +167,7 @@ namespace SafeExamBrowser.Browser
private void ReloadRequested()
{
- if (settings.AllowReloading && settings.ShowReloadWarning)
+ if (WindowSettings.AllowReloading && WindowSettings.ShowReloadWarning)
{
var result = messageBox.Show(TextKey.MessageBox_ReloadConfirmation, TextKey.MessageBox_ReloadConfirmationTitle, MessageBoxAction.YesNo, MessageBoxIcon.Question, window);
@@ -172,7 +181,7 @@ namespace SafeExamBrowser.Browser
logger.Debug("The user aborted reloading the current page.");
}
}
- else if (settings.AllowReloading)
+ else if (WindowSettings.AllowReloading)
{
logger.Debug("Reloading current page...");
control.Reload();
@@ -191,13 +200,13 @@ namespace SafeExamBrowser.Browser
private void Window_BackwardNavigationRequested()
{
- logger.Debug($"Navigating forwards...");
+ logger.Debug($"Navigating backwards...");
control.NavigateBackwards();
}
private void Window_ForwardNavigationRequested()
{
- logger.Debug($"Navigating backwards...");
+ logger.Debug($"Navigating forwards...");
control.NavigateForwards();
}
diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs
index 4a1d8444..359d4c66 100644
--- a/SafeExamBrowser.Browser/BrowserControl.cs
+++ b/SafeExamBrowser.Browser/BrowserControl.cs
@@ -28,6 +28,9 @@ namespace SafeExamBrowser.Browser
private LoadingStateChangedEventHandler loadingStateChanged;
private TitleChangedEventHandler titleChanged;
+ public bool CanNavigateBackwards => GetBrowser().CanGoBack;
+ public bool CanNavigateForwards => GetBrowser().CanGoForward;
+
event AddressChangedEventHandler IBrowserControl.AddressChanged
{
add { addressChanged += value; }
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs
index b25819ab..8faa8ba5 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs
@@ -17,8 +17,17 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
{
if (value is bool allow)
{
- settings.Browser.AllowBackwardNavigation = allow;
- settings.Browser.AllowForwardNavigation = allow;
+ settings.Browser.MainWindowSettings.AllowBackwardNavigation = allow;
+ settings.Browser.MainWindowSettings.AllowForwardNavigation = allow;
+ }
+ }
+
+ private void MapAllowNavigationAdditionalWindow(Settings settings, object value)
+ {
+ if (value is bool allow)
+ {
+ settings.Browser.AdditionalWindowSettings.AllowBackwardNavigation = allow;
+ settings.Browser.AdditionalWindowSettings.AllowForwardNavigation = allow;
}
}
@@ -42,7 +51,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
{
if (value is bool allow)
{
- settings.Browser.AllowReloading = allow;
+ settings.Browser.MainWindowSettings.AllowReloading = allow;
+ }
+ }
+
+ private void MapAllowReloadAdditionalWindow(Settings settings, object value)
+ {
+ if (value is bool allow)
+ {
+ settings.Browser.AdditionalWindowSettings.AllowReloading = allow;
}
}
@@ -52,7 +69,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
if (value is int mode)
{
- settings.Browser.FullScreenMode = mode == FULLSCREEN;
+ settings.Browser.MainWindowSettings.FullScreenMode = mode == FULLSCREEN;
}
}
@@ -60,7 +77,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
{
if (value is bool show)
{
- settings.Browser.ShowReloadWarning = show;
+ settings.Browser.MainWindowSettings.ShowReloadWarning = show;
+ }
+ }
+
+ private void MapShowReloadWarningAdditionalWindow(Settings settings, object value)
+ {
+ if (value is bool show)
+ {
+ settings.Browser.AdditionalWindowSettings.ShowReloadWarning = show;
}
}
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs
index 4e233184..3b68b333 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs
@@ -30,6 +30,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
case Keys.Browser.AllowNavigation:
MapAllowNavigation(settings, value);
break;
+ case Keys.Browser.AllowNavigationAdditionalWindow:
+ MapAllowNavigationAdditionalWindow(settings, value);
+ break;
case Keys.Browser.AllowPageZoom:
MapAllowPageZoom(settings, value);
break;
@@ -39,12 +42,18 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
case Keys.Browser.AllowReload:
MapAllowReload(settings, value);
break;
+ case Keys.Browser.AllowReloadAdditionalWindow:
+ MapAllowReloadAdditionalWindow(settings, value);
+ break;
case Keys.Browser.MainWindowMode:
MapMainWindowMode(settings, value);
break;
case Keys.Browser.ShowReloadWarning:
MapShowReloadWarning(settings, value);
break;
+ case Keys.Browser.ShowReloadWarningAdditionalWindow:
+ MapShowReloadWarningAdditionalWindow(settings, value);
+ break;
case Keys.ConfigurationFile.ConfigurationPurpose:
MapConfigurationMode(settings, value);
break;
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
index 44a90512..631baaf1 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
@@ -89,15 +89,23 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
var settings = new Settings();
settings.Browser.StartUrl = "https://www.safeexambrowser.org/start";
- settings.Browser.AllowAddressBar = false;
- settings.Browser.AllowBackwardNavigation = false;
settings.Browser.AllowConfigurationDownloads = true;
settings.Browser.AllowDeveloperConsole = false;
settings.Browser.AllowDownloads = false;
- settings.Browser.AllowForwardNavigation = false;
settings.Browser.AllowPageZoom = true;
settings.Browser.AllowPopups = true;
- settings.Browser.AllowReloading = true;
+ settings.Browser.AdditionalWindowSettings.AllowAddressBar = false;
+ settings.Browser.AdditionalWindowSettings.AllowBackwardNavigation = true;
+ settings.Browser.AdditionalWindowSettings.AllowForwardNavigation = true;
+ settings.Browser.AdditionalWindowSettings.AllowReloading = true;
+ settings.Browser.AdditionalWindowSettings.FullScreenMode = false;
+ settings.Browser.AdditionalWindowSettings.ShowReloadWarning = false;
+ settings.Browser.MainWindowSettings.AllowAddressBar = false;
+ settings.Browser.MainWindowSettings.AllowBackwardNavigation = false;
+ settings.Browser.MainWindowSettings.AllowForwardNavigation = false;
+ settings.Browser.MainWindowSettings.AllowReloading = true;
+ settings.Browser.MainWindowSettings.FullScreenMode = false;
+ settings.Browser.MainWindowSettings.ShowReloadWarning = true;
settings.Keyboard.AllowAltEsc = false;
settings.Keyboard.AllowAltF4 = false;
@@ -133,18 +141,10 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
settings.Taskbar.AllowWirelessNetwork = false;
settings.Taskbar.ShowClock = true;
- // TODO: Default values for alpha version only, remove for final release!
- settings.Browser.AllowAddressBar = true;
- settings.Browser.AllowBackwardNavigation = true;
- settings.Browser.AllowConfigurationDownloads = true;
+ // TODO: Default values for testing of alpha version only, remove for final release!
settings.Browser.AllowDeveloperConsole = true;
- settings.Browser.AllowDownloads = true;
- settings.Browser.AllowForwardNavigation = true;
- settings.Browser.AllowReloading = true;
settings.KioskMode = KioskMode.None;
- settings.ServicePolicy = ServicePolicy.Optional;
settings.Taskbar.AllowApplicationLog = true;
- settings.Taskbar.AllowWirelessNetwork = true;
return settings;
}
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
index 6377a547..52c0ed35 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
@@ -21,13 +21,16 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal static class Browser
{
internal const string AllowNavigation = "allowBrowsingBackForward";
+ internal const string AllowNavigationAdditionalWindow = "newBrowserWindowNavigation";
internal const string AllowPageZoom = "enableZoomPage";
internal const string AllowPopups = "blockPopUpWindows";
internal const string AllowReload = "browserWindowAllowReload";
+ internal const string AllowReloadAdditionalWindow = "newBrowserWindowAllowReload";
internal const string CustomUserAgentDesktop = "browserUserAgentWinDesktopModeCustom";
internal const string CustomUserAgentMobile = "browserUserAgentWinTouchModeCustom";
internal const string MainWindowMode = "browserViewMode";
internal const string ShowReloadWarning = "showReloadWarning";
+ internal const string ShowReloadWarningAdditionalWindow = "newBrowserWindowShowReloadWarning";
internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode";
internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode";
}
diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs
index c949b032..920e3496 100644
--- a/SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs
+++ b/SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs
@@ -11,20 +11,15 @@ using System;
namespace SafeExamBrowser.Contracts.Configuration.Settings
{
///
- /// Defines all configuration options for the browser of the application.
+ /// Defines all configuration options for the browser engine of the application.
///
[Serializable]
public class BrowserSettings
{
///
- /// Determines whether the user will be allowed to change the URL of a browser window.
+ /// The configuration to be used for additional browser windows.
///
- public bool AllowAddressBar { get; set; }
-
- ///
- /// Determines whether the user will be allowed to navigate backwards in a browser window.
- ///
- public bool AllowBackwardNavigation { get; set; }
+ public BrowserWindowSettings AdditionalWindowSettings { get; set; }
///
/// Determines whether the user will be allowed to download configuration files.
@@ -41,11 +36,6 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
///
public bool AllowDownloads { get; set; }
- ///
- /// Determines whether the user will be allowed to navigate forwards in a browser window.
- ///
- public bool AllowForwardNavigation { get; set; }
-
///
/// Determines whether the user will be allowed to zoom webpages.
///
@@ -56,28 +46,18 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
///
public bool AllowPopups { get; set; }
- ///
- /// Determines whether the user will be allowed to reload webpages.
- ///
- public bool AllowReloading { get; set; }
-
///
/// The custom user agent to optionally be used for all requests.
///
public string CustomUserAgent { get; set; }
///
- /// Determines whether the main browser window will be rendered in fullscreen mode, i.e. without window frame.
+ /// The configuration to be used for the main browser window.
///
- public bool FullScreenMode { get; set; }
-
+ public BrowserWindowSettings MainWindowSettings { get; set; }
+
///
- /// Determines whether the user will need to confirm every reload attempt.
- ///
- public bool ShowReloadWarning { get; set; }
-
- ///
- /// The start URL with which a new browser window will be loaded.
+ /// The URL with which the main browser window will be loaded.
///
public string StartUrl { get; set; }
@@ -85,5 +65,11 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
/// Determines whether a custom user agent will be used for all requests, see .
///
public bool UseCustomUserAgent { get; set; }
+
+ public BrowserSettings()
+ {
+ AdditionalWindowSettings = new BrowserWindowSettings();
+ MainWindowSettings = new BrowserWindowSettings();
+ }
}
}
diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/BrowserWindowSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/BrowserWindowSettings.cs
new file mode 100644
index 00000000..c76c3f7e
--- /dev/null
+++ b/SafeExamBrowser.Contracts/Configuration/Settings/BrowserWindowSettings.cs
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+using System;
+
+namespace SafeExamBrowser.Contracts.Configuration.Settings
+{
+ ///
+ /// Defines all configuration options for a window of the browser engine.
+ ///
+ [Serializable]
+ public class BrowserWindowSettings
+ {
+ ///
+ /// Determines whether the user will be allowed to change the URL in the address bar.
+ ///
+ public bool AllowAddressBar { get; set; }
+
+ ///
+ /// Determines whether the user will be allowed to navigate backwards.
+ ///
+ public bool AllowBackwardNavigation { get; set; }
+
+ ///
+ /// Determines whether the user will be allowed to navigate forwards.
+ ///
+ public bool AllowForwardNavigation { get; set; }
+
+ ///
+ /// Determines whether the user will be allowed to reload webpages.
+ ///
+ public bool AllowReloading { get; set; }
+
+ ///
+ /// Determines whether the browser window will be rendered in fullscreen mode, i.e. without window frame.
+ ///
+ public bool FullScreenMode { get; set; }
+
+ ///
+ /// Determines whether the user will need to confirm every reload attempt.
+ ///
+ public bool ShowReloadWarning { get; set; }
+ }
+}
diff --git a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj
index 1b1402f2..8a28d628 100644
--- a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj
+++ b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj
@@ -70,6 +70,7 @@
+
diff --git a/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserControl.cs b/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserControl.cs
index 851ae959..91152b27 100644
--- a/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserControl.cs
+++ b/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserControl.cs
@@ -16,6 +16,16 @@ namespace SafeExamBrowser.Contracts.UserInterface.Browser
///
public interface IBrowserControl
{
+ ///
+ /// Indicates whether a backward navigation can be performed.
+ ///
+ bool CanNavigateBackwards { get; }
+
+ ///
+ /// Indicates whether a forward navigation can be performed.
+ ///
+ bool CanNavigateForwards { get; }
+
///
/// Event fired when the address of the browser control changes.
///
diff --git a/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserWindow.cs b/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserWindow.cs
index 6988bfeb..3245b872 100644
--- a/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserWindow.cs
+++ b/SafeExamBrowser.Contracts/UserInterface/Browser/IBrowserWindow.cs
@@ -17,6 +17,16 @@ namespace SafeExamBrowser.Contracts.UserInterface.Browser
///
public interface IBrowserWindow : IWindow
{
+ ///
+ /// Enables the backward navigation button.
+ ///
+ bool CanNavigateBackwards { set; }
+
+ ///
+ /// Enables the forward navigation button.
+ ///
+ bool CanNavigateForwards { set; }
+
///
/// Event fired when the user changed the URL.
///
@@ -52,11 +62,6 @@ namespace SafeExamBrowser.Contracts.UserInterface.Browser
///
event ActionRequestedEventHandler ZoomResetRequested;
- ///
- /// Determines whether this window is the main browser window.
- ///
- bool IsMainWindow { get; set; }
-
///
/// Updates the address bar of the browser window to the given value;
///
diff --git a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs
index 400400e9..8f9dc79e 100644
--- a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs
+++ b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs
@@ -36,7 +36,7 @@ namespace SafeExamBrowser.Contracts.UserInterface
///
/// Creates a new browser window loaded with the given browser control and settings.
///
- IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings);
+ IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings, bool isMainWindow);
///
/// Creates a system control which allows to change the keyboard layout of the computer.
diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml
index a51ac5bb..e399c81f 100644
--- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml
+++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml
@@ -29,7 +29,7 @@
-
+
diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs
index cd29050c..3206d5dd 100644
--- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs
+++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs
@@ -31,19 +31,14 @@ namespace SafeExamBrowser.UserInterface.Desktop
private IText text;
private WindowClosingEventHandler closing;
- public bool IsMainWindow
+ private BrowserWindowSettings WindowSettings
{
- get
- {
- return isMainWindow;
- }
- set
- {
- isMainWindow = value;
- ApplySettings();
- }
+ get { return isMainWindow ? settings.MainWindowSettings : settings.AdditionalWindowSettings; }
}
+ public bool CanNavigateBackwards { set => Dispatcher.Invoke(() => BackwardButton.IsEnabled = value); }
+ public bool CanNavigateForwards { set => Dispatcher.Invoke(() => ForwardButton.IsEnabled = value); }
+
public event AddressChangedEventHandler AddressChanged;
public event ActionRequestedEventHandler BackwardNavigationRequested;
public event ActionRequestedEventHandler ForwardNavigationRequested;
@@ -58,8 +53,9 @@ namespace SafeExamBrowser.UserInterface.Desktop
remove { closing -= value; }
}
- public BrowserWindow(IBrowserControl browserControl, BrowserSettings settings, IText text)
+ public BrowserWindow(IBrowserControl browserControl, BrowserSettings settings, bool isMainWindow, IText text)
{
+ this.isMainWindow = isMainWindow;
this.settings = settings;
this.text = text;
@@ -128,7 +124,7 @@ namespace SafeExamBrowser.UserInterface.Desktop
BrowserControlHost.Child = control;
}
- BackButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
+ BackwardButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
Closing += (o, args) => closing?.Invoke();
ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
MenuButton.Click += (o, args) => MenuPopup.IsOpen = !MenuPopup.IsOpen;
@@ -180,9 +176,9 @@ namespace SafeExamBrowser.UserInterface.Desktop
private void ApplySettings()
{
- if (IsMainWindow)
+ if (isMainWindow)
{
- if (settings.FullScreenMode)
+ if (WindowSettings.FullScreenMode)
{
MaxHeight = SystemParameters.WorkArea.Height;
ResizeMode = ResizeMode.NoResize;
@@ -202,16 +198,16 @@ namespace SafeExamBrowser.UserInterface.Desktop
Width = SystemParameters.WorkArea.Width / 2;
}
- UrlTextBox.IsEnabled = settings.AllowAddressBar;
+ UrlTextBox.IsEnabled = WindowSettings.AllowAddressBar;
- ReloadButton.IsEnabled = settings.AllowReloading;
- ReloadButton.Visibility = settings.AllowReloading ? Visibility.Visible : Visibility.Collapsed;
+ ReloadButton.IsEnabled = WindowSettings.AllowReloading;
+ ReloadButton.Visibility = WindowSettings.AllowReloading ? Visibility.Visible : Visibility.Collapsed;
- BackButton.IsEnabled = settings.AllowBackwardNavigation;
- BackButton.Visibility = settings.AllowBackwardNavigation ? Visibility.Visible : Visibility.Collapsed;
+ BackwardButton.IsEnabled = WindowSettings.AllowBackwardNavigation;
+ BackwardButton.Visibility = WindowSettings.AllowBackwardNavigation ? Visibility.Visible : Visibility.Collapsed;
- ForwardButton.IsEnabled = settings.AllowForwardNavigation;
- ForwardButton.Visibility = settings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
+ ForwardButton.IsEnabled = WindowSettings.AllowForwardNavigation;
+ ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
}
private void LoadIcons()
@@ -220,12 +216,12 @@ namespace SafeExamBrowser.UserInterface.Desktop
var forwardUri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/NavigateForward.xaml");
var menuUri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Menu.xaml");
var reloadUri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Reload.xaml");
- var back = new XamlIconResource(backUri);
+ var backward = new XamlIconResource(backUri);
var forward = new XamlIconResource(forwardUri);
var menu = new XamlIconResource(menuUri);
var reload = new XamlIconResource(reloadUri);
- BackButton.Content = IconResourceLoader.Load(back);
+ BackwardButton.Content = IconResourceLoader.Load(backward);
ForwardButton.Content = IconResourceLoader.Load(forward);
MenuButton.Content = IconResourceLoader.Load(menu);
ReloadButton.Content = IconResourceLoader.Load(reload);
diff --git a/SafeExamBrowser.UserInterface.Desktop/Templates/Buttons.xaml b/SafeExamBrowser.UserInterface.Desktop/Templates/Buttons.xaml
index 0f1f2785..b7b9b189 100644
--- a/SafeExamBrowser.UserInterface.Desktop/Templates/Buttons.xaml
+++ b/SafeExamBrowser.UserInterface.Desktop/Templates/Buttons.xaml
@@ -28,6 +28,9 @@
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="{TemplateBinding VerticalAlignment}" />
+
+
+
diff --git a/SafeExamBrowser.UserInterface.Desktop/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Desktop/UserInterfaceFactory.cs
index 1e872eff..3b90f8c5 100644
--- a/SafeExamBrowser.UserInterface.Desktop/UserInterfaceFactory.cs
+++ b/SafeExamBrowser.UserInterface.Desktop/UserInterfaceFactory.cs
@@ -43,9 +43,9 @@ namespace SafeExamBrowser.UserInterface.Desktop
return new ApplicationButton(info);
}
- public IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings)
+ public IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings, bool isMainWindow)
{
- return new BrowserWindow(control, settings, text);
+ return new BrowserWindow(control, settings, isMainWindow, text);
}
public ISystemKeyboardLayoutControl CreateKeyboardLayoutControl()