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 @@ - + + + +