diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
index f2daad50..54ba653f 100644
--- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
+++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
@@ -32,6 +32,7 @@ namespace SafeExamBrowser.Browser
control = new BrowserControl(settings, text);
control.AddressChanged += Control_AddressChanged;
+ control.LoadingStateChanged += Control_LoadingStateChanged;
control.TitleChanged += Control_TitleChanged;
window = uiFactory.CreateBrowserWindow(control, settings);
@@ -48,6 +49,11 @@ namespace SafeExamBrowser.Browser
window.UpdateAddress(address);
}
+ private void Control_LoadingStateChanged(bool isLoading)
+ {
+ window.UpdateLoadingState(isLoading);
+ }
+
private void Control_TitleChanged(string title)
{
window.UpdateTitle(title);
diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs
index d3f45254..7a98b313 100644
--- a/SafeExamBrowser.Browser/BrowserControl.cs
+++ b/SafeExamBrowser.Browser/BrowserControl.cs
@@ -15,19 +15,27 @@ using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.Browser
namespace SafeExamBrowser.Browser
{
- class BrowserControl : ChromiumWebBrowser, IBrowserControl
+ internal class BrowserControl : ChromiumWebBrowser, IBrowserControl
{
- private AddressChangedEventHandler addressChanged;
private BrowserSettings settings;
- private TitleChangedEventHandler titleChanged;
private IText text;
+ private AddressChangedEventHandler addressChanged;
+ private LoadingStateChangedEventHandler loadingStateChanged;
+ private TitleChangedEventHandler titleChanged;
+
event AddressChangedEventHandler IBrowserControl.AddressChanged
{
add { addressChanged += value; }
remove { addressChanged -= value; }
}
+ event LoadingStateChangedEventHandler IBrowserControl.LoadingStateChanged
+ {
+ add { loadingStateChanged += value; }
+ remove { loadingStateChanged -= value; }
+ }
+
event TitleChangedEventHandler IBrowserControl.TitleChanged
{
add { titleChanged += value; }
@@ -68,6 +76,7 @@ namespace SafeExamBrowser.Browser
private void Initialize()
{
AddressChanged += (o, args) => addressChanged?.Invoke(args.Address);
+ LoadingStateChanged += (o, args) => loadingStateChanged?.Invoke(args.IsLoading);
TitleChanged += (o, args) => titleChanged?.Invoke(args.Title);
MenuHandler = new BrowserContextMenuHandler(settings, text);
diff --git a/SafeExamBrowser.Contracts/UserInterface/IBrowserControl.cs b/SafeExamBrowser.Contracts/UserInterface/IBrowserControl.cs
index 48418eb4..da331f5b 100644
--- a/SafeExamBrowser.Contracts/UserInterface/IBrowserControl.cs
+++ b/SafeExamBrowser.Contracts/UserInterface/IBrowserControl.cs
@@ -9,6 +9,7 @@
namespace SafeExamBrowser.Contracts.UserInterface
{
public delegate void AddressChangedEventHandler(string address);
+ public delegate void LoadingStateChangedEventHandler(bool isLoading);
public delegate void TitleChangedEventHandler(string title);
public interface IBrowserControl
@@ -18,6 +19,11 @@ namespace SafeExamBrowser.Contracts.UserInterface
///
event AddressChangedEventHandler AddressChanged;
+ ///
+ /// Event fired when the loading state of the browser control changes.
+ ///
+ event LoadingStateChangedEventHandler LoadingStateChanged;
+
///
/// Event fired when the current page (and thus the title) of the browser control changes.
///
diff --git a/SafeExamBrowser.Contracts/UserInterface/IBrowserWindow.cs b/SafeExamBrowser.Contracts/UserInterface/IBrowserWindow.cs
index c50563b2..1238f18c 100644
--- a/SafeExamBrowser.Contracts/UserInterface/IBrowserWindow.cs
+++ b/SafeExamBrowser.Contracts/UserInterface/IBrowserWindow.cs
@@ -42,6 +42,11 @@ namespace SafeExamBrowser.Contracts.UserInterface
///
void UpdateAddress(string adress);
+ ///
+ /// Updates the loading state according to the given value.
+ ///
+ void UpdateLoadingState(bool isLoading);
+
///
/// Sets the title of the browser window to the given value;
///
diff --git a/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml b/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml
index b5209019..f0a98f70 100644
--- a/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml
+++ b/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml
@@ -3,8 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Classic"
- mc:Ignorable="d" Title="BrowserWindow" Background="#FFF0F0F0" Height="500" Width="500" WindowState="Maximized" Icon=".\Images\SafeExamBrowser.ico">
+ mc:Ignorable="d" Title="BrowserWindow" Background="#FFF0F0F0" Height="500" Width="750" WindowState="Maximized" Icon=".\Images\SafeExamBrowser.ico">
@@ -26,7 +27,10 @@
-
+
+
+
+
diff --git a/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs
index c818243c..25816a77 100644
--- a/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs
+++ b/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs
@@ -86,6 +86,11 @@ namespace SafeExamBrowser.UserInterface.Classic
Dispatcher.Invoke(() => UrlTextBox.Text = url);
}
+ public void UpdateLoadingState(bool isLoading)
+ {
+ Dispatcher.Invoke(() => LoadingIcon.Visibility = isLoading ? Visibility.Visible : Visibility.Collapsed);
+ }
+
public void UpdateTitle(string title)
{
Dispatcher.Invoke(() => Title = title);
diff --git a/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs
index 3401513d..2befd0d8 100644
--- a/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs
+++ b/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs
@@ -7,141 +7,138 @@
*/
using System.Windows;
-using System.Windows.Input;
-using SafeExamBrowser.Contracts.Configuration.Settings;
-using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.UserInterface.Windows10
{
- public partial class BrowserWindow : Window, IBrowserWindow
+ public partial class BrowserWindow : Window // TODO, IBrowserWindow
{
- private bool isMainWindow;
- private BrowserSettings settings;
- public WindowClosingEventHandler closing;
+ //private bool isMainWindow;
+ //private BrowserSettings settings;
+ //public WindowClosingEventHandler closing;
- public bool IsMainWindow
- {
- get
- {
- return isMainWindow;
- }
- set
- {
- isMainWindow = value;
- ApplySettings();
- }
- }
+ //public bool IsMainWindow
+ //{
+ // get
+ // {
+ // return isMainWindow;
+ // }
+ // set
+ // {
+ // isMainWindow = value;
+ // ApplySettings();
+ // }
+ //}
- public event AddressChangedEventHandler AddressChanged;
- public event ActionRequestedEventHandler BackwardNavigationRequested;
- public event ActionRequestedEventHandler ForwardNavigationRequested;
- public event ActionRequestedEventHandler ReloadRequested;
+ //public event AddressChangedEventHandler AddressChanged;
+ //public event ActionRequestedEventHandler BackwardNavigationRequested;
+ //public event ActionRequestedEventHandler ForwardNavigationRequested;
+ //public event ActionRequestedEventHandler ReloadRequested;
- event WindowClosingEventHandler IWindow.Closing
- {
- add { closing += value; }
- remove { closing -= value; }
- }
+ //event WindowClosingEventHandler IWindow.Closing
+ //{
+ // add { closing += value; }
+ // remove { closing -= value; }
+ //}
- public BrowserWindow(IBrowserControl browserControl, BrowserSettings settings)
- {
- this.settings = settings;
+ //public BrowserWindow(IBrowserControl browserControl, BrowserSettings settings)
+ //{
+ // this.settings = settings;
- InitializeComponent();
- InitializeBrowserWindow(browserControl);
- }
+ // InitializeComponent();
+ // InitializeBrowserWindow(browserControl);
+ //}
- public void BringToForeground()
- {
- Dispatcher.Invoke(() =>
- {
- if (WindowState == WindowState.Minimized)
- {
- WindowState = WindowState.Normal;
- }
+ //public void BringToForeground()
+ //{
+ // Dispatcher.Invoke(() =>
+ // {
+ // if (WindowState == WindowState.Minimized)
+ // {
+ // WindowState = WindowState.Normal;
+ // }
- Activate();
- });
- }
+ // Activate();
+ // });
+ //}
- public new void Close()
- {
- Dispatcher.Invoke(base.Close);
- }
+ //public new void Close()
+ //{
+ // Dispatcher.Invoke(base.Close);
+ //}
- public new void Hide()
- {
- Dispatcher.Invoke(base.Hide);
- }
+ //public new void Hide()
+ //{
+ // Dispatcher.Invoke(base.Hide);
+ //}
- public new void Show()
- {
- Dispatcher.Invoke(base.Show);
- }
+ //public new void Show()
+ //{
+ // Dispatcher.Invoke(base.Show);
+ //}
- public void UpdateAddress(string url)
- {
- Dispatcher.Invoke(() => UrlTextBox.Text = url);
- }
+ //public void UpdateAddress(string url)
+ //{
+ // Dispatcher.Invoke(() => UrlTextBox.Text = url);
+ //}
- public void UpdateTitle(string title)
- {
- Dispatcher.Invoke(() => Title = title);
- }
+ //public void UpdateTitle(string title)
+ //{
+ // Dispatcher.Invoke(() => Title = title);
+ //}
- private void InitializeBrowserWindow(IBrowserControl browserControl)
- {
- if (browserControl is System.Windows.Forms.Control control)
- {
- BrowserControlHost.Child = control;
- }
+ //private void InitializeBrowserWindow(IBrowserControl browserControl)
+ //{
+ // if (browserControl is System.Windows.Forms.Control control)
+ // {
+ // BrowserControlHost.Child = control;
+ // }
- Closing += (o, args) => closing?.Invoke();
- KeyUp += BrowserWindow_KeyUp;
- UrlTextBox.KeyUp += UrlTextBox_KeyUp;
- ReloadButton.Click += (o, args) => ReloadRequested?.Invoke();
- BackButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
- ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
+ // Closing += (o, args) => closing?.Invoke();
+ // KeyUp += BrowserWindow_KeyUp;
+ // UrlTextBox.KeyUp += UrlTextBox_KeyUp;
+ // ReloadButton.Click += (o, args) => ReloadRequested?.Invoke();
+ // BackButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
+ // ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
- ApplySettings();
- }
+ // ApplySettings();
+ //}
- private void BrowserWindow_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.F5)
- {
- ReloadRequested?.Invoke();
- }
- }
+ //private void BrowserWindow_KeyUp(object sender, KeyEventArgs e)
+ //{
+ // if (e.Key == Key.F5)
+ // {
+ // ReloadRequested?.Invoke();
+ // }
+ //}
- private void UrlTextBox_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- AddressChanged?.Invoke(UrlTextBox.Text);
- }
- }
+ //private void UrlTextBox_KeyUp(object sender, KeyEventArgs e)
+ //{
+ // if (e.Key == Key.Enter)
+ // {
+ // AddressChanged?.Invoke(UrlTextBox.Text);
+ // }
+ //}
- private void ApplySettings()
- {
- if (IsMainWindow && settings.FullScreenMode)
- {
- MaxHeight = SystemParameters.WorkArea.Height;
- ResizeMode = ResizeMode.NoResize;
- WindowState = WindowState.Maximized;
- WindowStyle = WindowStyle.None;
- }
+ //private void ApplySettings()
+ //{
+ // if (IsMainWindow && settings.FullScreenMode)
+ // {
+ // MaxHeight = SystemParameters.WorkArea.Height;
+ // ResizeMode = ResizeMode.NoResize;
+ // WindowState = WindowState.Maximized;
+ // WindowStyle = WindowStyle.None;
+ // }
- UrlTextBox.IsEnabled = settings.AllowAddressBar;
+ // UrlTextBox.IsEnabled = settings.AllowAddressBar;
- ReloadButton.IsEnabled = settings.AllowReloading;
- ReloadButton.Visibility = settings.AllowReloading ? Visibility.Visible : Visibility.Collapsed;
+ // ReloadButton.IsEnabled = settings.AllowReloading;
+ // ReloadButton.Visibility = settings.AllowReloading ? Visibility.Visible : Visibility.Collapsed;
- BackButton.IsEnabled = settings.AllowBackwardNavigation;
- BackButton.Visibility = settings.AllowBackwardNavigation ? Visibility.Visible : Visibility.Collapsed;
+ // BackButton.IsEnabled = settings.AllowBackwardNavigation;
+ // BackButton.Visibility = settings.AllowBackwardNavigation ? Visibility.Visible : Visibility.Collapsed;
- ForwardButton.IsEnabled = settings.AllowForwardNavigation;
- ForwardButton.Visibility = settings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
- }
+ // ForwardButton.IsEnabled = settings.AllowForwardNavigation;
+ // ForwardButton.Visibility = settings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
+ //}
}
}
diff --git a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs
index 782b0af0..3933934e 100644
--- a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs
+++ b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs
@@ -40,7 +40,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
public IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings)
{
- return new BrowserWindow(control, settings);
+ // TODO
+ // return new BrowserWindow(control, settings);
+ throw new System.NotImplementedException();
}
public IWindow CreateLogWindow(ILogger logger)