diff --git a/SafeExamBrowser.Client/app.manifest b/SafeExamBrowser.Client/app.manifest index 255ae2a8..05666ac8 100644 --- a/SafeExamBrowser.Client/app.manifest +++ b/SafeExamBrowser.Client/app.manifest @@ -58,7 +58,6 @@ --> - diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs index 4a2f63ae..b5642c19 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs @@ -17,14 +17,18 @@ namespace SafeExamBrowser.Configuration.ConfigurationData { foreach (var item in rawData) { - Map(item.Key, item.Value, settings); + MapBrowserSettings(item.Key, item.Value, settings); + MapConfigurationFileSettings(item.Key, item.Value, settings); + MapGeneralSettings(item.Key, item.Value, settings); + MapInputSettings(item.Key, item.Value, settings); + MapUserInterfaceSettings(item.Key, item.Value, settings); } MapKioskMode(rawData, settings); MapUserAgentMode(rawData, settings); } - private void Map(string key, object value, Settings settings) + private void MapBrowserSettings(string key, object value, Settings settings) { switch (key) { @@ -61,9 +65,23 @@ namespace SafeExamBrowser.Configuration.ConfigurationData case Keys.Browser.ShowReloadWarningAdditionalWindow: MapShowReloadWarningAdditionalWindow(settings, value); break; + } + } + + private void MapConfigurationFileSettings(string key, object value, Settings settings) + { + switch (key) + { case Keys.ConfigurationFile.ConfigurationPurpose: MapConfigurationMode(settings, value); break; + } + } + + private void MapGeneralSettings(string key, object value, Settings settings) + { + switch (key) + { case Keys.General.AdminPasswordHash: MapAdminPasswordHash(settings, value); break; @@ -76,6 +94,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData case Keys.General.StartUrl: MapStartUrl(settings, value); break; + } + } + + private void MapInputSettings(string key, object value, Settings settings) + { + switch (key) + { case Keys.Input.Keyboard.EnableAltEsc: MapEnableAltEsc(settings, value); break; @@ -136,6 +161,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData case Keys.Input.Mouse.EnableRightMouse: MapEnableRightMouse(settings, value); break; + } + } + + private void MapUserInterfaceSettings(string key, object value, Settings settings) + { + switch (key) + { case Keys.UserInterface.AllowKeyboardLayout: MapKeyboardLayout(settings, value); break; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index c7e58ede..e0b2d398 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -149,12 +149,10 @@ namespace SafeExamBrowser.Configuration.ConfigurationData settings.Taskbar.ShowClock = true; settings.UserInterfaceMode = UserInterfaceMode.Desktop; - - // TODO: Default values for testing of alpha version only, remove for final release! + + // TODO: Default value overrides for alpha version, remove for final release! settings.ActionCenter.ShowApplicationLog = true; settings.Browser.AllowDeveloperConsole = true; - settings.Browser.MainWindowSettings.AllowAddressBar = true; - settings.Taskbar.ShowApplicationLog = true; return settings; } diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs index 86152eb5..fd0edf05 100644 --- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs @@ -22,7 +22,7 @@ using SafeExamBrowser.Contracts.UserInterface.Browser; using SafeExamBrowser.Contracts.UserInterface.Browser.Events; using SafeExamBrowser.Contracts.UserInterface.Windows; using SafeExamBrowser.Contracts.UserInterface.Windows.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop { @@ -100,7 +100,7 @@ namespace SafeExamBrowser.UserInterface.Desktop public void UpdateAddress(string url) { - Dispatcher.Invoke(() => UrlTextBox.Text = url); + Dispatcher.Invoke(() => UrlTextBox.Text = WindowSettings.AllowAddressBar ? url : UrlRandomizer.Randomize(url)); } public void UpdateIcon(IIconResource icon) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterApplicationButton.xaml.cs index 89d6efd4..79762a39 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterApplicationButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.Core; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml.cs index b435ec99..0de1edf6 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Client; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterQuitButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterQuitButton.xaml.cs index 3741d70e..e2fa4030 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterQuitButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterQuitButton.xaml.cs @@ -10,7 +10,7 @@ using System; using System.ComponentModel; using System.Windows.Controls; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterWirelessNetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterWirelessNetworkControl.xaml.cs index 9e037a60..a21bf30c 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterWirelessNetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterWirelessNetworkControl.xaml.cs @@ -16,7 +16,7 @@ using FontAwesome.WPF; using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationControl.xaml.cs index b94aa9b5..096d7ca9 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationControl.xaml.cs @@ -16,7 +16,7 @@ using System.Windows.Threading; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationInstanceButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationInstanceButton.xaml.cs index 595af9f6..3f3f7408 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationInstanceButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarApplicationInstanceButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.Core; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarNotificationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarNotificationButton.xaml.cs index 7d321eee..9ae822e1 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarNotificationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarNotificationButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Client; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarQuitButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarQuitButton.xaml.cs index 2cdc0ee7..2a255ae5 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarQuitButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarQuitButton.xaml.cs @@ -11,7 +11,7 @@ using System.ComponentModel; using System.Windows; using System.Windows.Controls; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarWirelessNetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarWirelessNetworkControl.xaml.cs index 6c655c7d..a9760d68 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarWirelessNetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/TaskbarWirelessNetworkControl.xaml.cs @@ -16,7 +16,7 @@ using FontAwesome.WPF; using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop.Controls { diff --git a/SafeExamBrowser.UserInterface.Desktop/SafeExamBrowser.UserInterface.Desktop.csproj b/SafeExamBrowser.UserInterface.Desktop/SafeExamBrowser.UserInterface.Desktop.csproj index aea4f425..45c21860 100644 --- a/SafeExamBrowser.UserInterface.Desktop/SafeExamBrowser.UserInterface.Desktop.csproj +++ b/SafeExamBrowser.UserInterface.Desktop/SafeExamBrowser.UserInterface.Desktop.csproj @@ -148,9 +148,6 @@ SplashScreen.xaml - - - @@ -373,6 +370,10 @@ {47DA5933-BEF8-4729-94E6-ABDE2DB12262} SafeExamBrowser.Contracts + + {38525928-87ba-4f8c-8010-4eb97bfaae13} + SafeExamBrowser.UserInterface.Shared + diff --git a/SafeExamBrowser.UserInterface.Desktop/Taskbar.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Taskbar.xaml.cs index 24deb9c7..415028bf 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Taskbar.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Taskbar.xaml.cs @@ -12,7 +12,7 @@ using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Desktop.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Desktop { diff --git a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs index 812e4240..f05ef415 100644 --- a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs @@ -22,7 +22,7 @@ using SafeExamBrowser.Contracts.UserInterface.Browser; using SafeExamBrowser.Contracts.UserInterface.Browser.Events; using SafeExamBrowser.Contracts.UserInterface.Windows; using SafeExamBrowser.Contracts.UserInterface.Windows.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile { @@ -100,7 +100,7 @@ namespace SafeExamBrowser.UserInterface.Mobile public void UpdateAddress(string url) { - Dispatcher.Invoke(() => UrlTextBox.Text = url); + Dispatcher.Invoke(() => UrlTextBox.Text = WindowSettings.AllowAddressBar ? url : UrlRandomizer.Randomize(url)); } public void UpdateIcon(IIconResource icon) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterApplicationButton.xaml.cs index 044d4de7..f63827b6 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterApplicationButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.Core; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterNotificationButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterNotificationButton.xaml.cs index 8f7ec048..ff395561 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterNotificationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterNotificationButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Client; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterQuitButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterQuitButton.xaml.cs index 3ebcc509..ab13b183 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterQuitButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterQuitButton.xaml.cs @@ -10,7 +10,7 @@ using System; using System.ComponentModel; using System.Windows.Controls; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterWirelessNetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterWirelessNetworkControl.xaml.cs index 38b07766..262e9e09 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterWirelessNetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenterWirelessNetworkControl.xaml.cs @@ -16,7 +16,7 @@ using FontAwesome.WPF; using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationControl.xaml.cs index 2e59fe6e..5a3b7c1b 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationControl.xaml.cs @@ -16,7 +16,7 @@ using System.Windows.Threading; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationInstanceButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationInstanceButton.xaml.cs index 8aab1fee..50219f9c 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationInstanceButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarApplicationInstanceButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.Core; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarNotificationButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarNotificationButton.xaml.cs index 55e77802..23c9ee06 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarNotificationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarNotificationButton.xaml.cs @@ -11,7 +11,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Client; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarQuitButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarQuitButton.xaml.cs index 79ef83f4..0eb372c2 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarQuitButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarQuitButton.xaml.cs @@ -11,7 +11,7 @@ using System.ComponentModel; using System.Windows; using System.Windows.Controls; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarWirelessNetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarWirelessNetworkControl.xaml.cs index 4042bac0..0cfb6239 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarWirelessNetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/TaskbarWirelessNetworkControl.xaml.cs @@ -16,7 +16,7 @@ using FontAwesome.WPF; using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile.Controls { diff --git a/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj b/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj index 8ee15ff4..486d58cb 100644 --- a/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj +++ b/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj @@ -159,9 +159,6 @@ Taskbar.xaml - - - @@ -172,6 +169,10 @@ {47da5933-bef8-4729-94e6-abde2db12262} SafeExamBrowser.Contracts + + {38525928-87ba-4f8c-8010-4eb97bfaae13} + SafeExamBrowser.UserInterface.Shared + diff --git a/SafeExamBrowser.UserInterface.Mobile/Taskbar.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Taskbar.xaml.cs index c0cc5145..2ff991bb 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Taskbar.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Taskbar.xaml.cs @@ -12,7 +12,7 @@ using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.UserInterface.Shell; using SafeExamBrowser.Contracts.UserInterface.Shell.Events; -using SafeExamBrowser.UserInterface.Mobile.Utilities; +using SafeExamBrowser.UserInterface.Shared.Utilities; namespace SafeExamBrowser.UserInterface.Mobile { diff --git a/SafeExamBrowser.UserInterface.Mobile/Utilities/IconResourceLoader.cs b/SafeExamBrowser.UserInterface.Mobile/Utilities/IconResourceLoader.cs deleted file mode 100644 index 54671505..00000000 --- a/SafeExamBrowser.UserInterface.Mobile/Utilities/IconResourceLoader.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Markup; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using SafeExamBrowser.Contracts.Core; - -namespace SafeExamBrowser.UserInterface.Mobile.Utilities -{ - /// - /// TODO: Move to shared library? - /// - internal static class IconResourceLoader - { - internal static UIElement Load(IIconResource resource) - { - try - { - if (resource.IsBitmapResource) - { - return LoadBitmapResource(resource); - } - else if (resource.IsXamlResource) - { - return LoadXamlResource(resource); - } - } - catch (Exception) - { - return NotFoundSymbol(); - } - - throw new NotSupportedException($"Application icon resource of type '{resource.GetType()}' is not supported!"); - } - - private static UIElement LoadBitmapResource(IIconResource resource) - { - return new Image - { - Source = new BitmapImage(resource.Uri) - }; - } - - private static UIElement LoadXamlResource(IIconResource resource) - { - using (var stream = Application.GetResourceStream(resource.Uri)?.Stream) - { - return XamlReader.Load(stream) as UIElement; - } - } - - private static UIElement NotFoundSymbol() - { - return new TextBlock(new Run("X") { Foreground = Brushes.Red, FontWeight = FontWeights.Bold }) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center - }; - } - } -} diff --git a/SafeExamBrowser.UserInterface.Mobile/Utilities/VisualExtensions.cs b/SafeExamBrowser.UserInterface.Mobile/Utilities/VisualExtensions.cs deleted file mode 100644 index 4a6a7d92..00000000 --- a/SafeExamBrowser.UserInterface.Mobile/Utilities/VisualExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.Windows; -using System.Windows.Interop; -using System.Windows.Media; - -namespace SafeExamBrowser.UserInterface.Mobile.Utilities -{ - /// - /// TODO: Move to shared library? - /// - internal static class VisualExtensions - { - /// - /// WPF works with device-independent pixels. This method is required to - /// transform such values to their absolute, device-specific pixel value. - /// Source: https://stackoverflow.com/questions/3286175/how-do-i-convert-a-wpf-size-to-physical-pixels - /// - internal static Vector TransformToPhysical(this Visual visual, double x, double y) - { - Matrix transformToDevice; - var source = PresentationSource.FromVisual(visual); - - if (source != null) - { - transformToDevice = source.CompositionTarget.TransformToDevice; - } - else - { - using (var newSource = new HwndSource(new HwndSourceParameters())) - { - transformToDevice = newSource.CompositionTarget.TransformToDevice; - } - } - - return transformToDevice.Transform(new Vector(x, y)); - } - } -} diff --git a/SafeExamBrowser.UserInterface.Mobile/Utilities/XamlIconResource.cs b/SafeExamBrowser.UserInterface.Mobile/Utilities/XamlIconResource.cs deleted file mode 100644 index 5e74c5a2..00000000 --- a/SafeExamBrowser.UserInterface.Mobile/Utilities/XamlIconResource.cs +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; -using SafeExamBrowser.Contracts.Core; - -namespace SafeExamBrowser.UserInterface.Mobile.Utilities -{ - /// - /// TODO: Move to shared library? - /// - internal class XamlIconResource : IIconResource - { - public Uri Uri { get; private set; } - public bool IsBitmapResource => false; - public bool IsXamlResource => true; - - public XamlIconResource(Uri uri) - { - Uri = uri; - } - } -} diff --git a/SafeExamBrowser.UserInterface.Shared/Properties/AssemblyInfo.cs b/SafeExamBrowser.UserInterface.Shared/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7bd61994 --- /dev/null +++ b/SafeExamBrowser.UserInterface.Shared/Properties/AssemblyInfo.cs @@ -0,0 +1,51 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SafeExamBrowser.UserInterface.Shared")] +[assembly: AssemblyDescription("Safe Exam Browser")] +[assembly: AssemblyCompany("ETH Zürich")] +[assembly: AssemblyProduct("SafeExamBrowser.UserInterface.Shared")] +[assembly: AssemblyCopyright("Copyright © 2019 ETH Zürich, Educational Development and Technology (LET)")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/SafeExamBrowser.UserInterface.Shared/SafeExamBrowser.UserInterface.Shared.csproj b/SafeExamBrowser.UserInterface.Shared/SafeExamBrowser.UserInterface.Shared.csproj new file mode 100644 index 00000000..3b9fe27f --- /dev/null +++ b/SafeExamBrowser.UserInterface.Shared/SafeExamBrowser.UserInterface.Shared.csproj @@ -0,0 +1,79 @@ + + + + + Debug + AnyCPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13} + library + SafeExamBrowser.UserInterface.Shared + SafeExamBrowser.UserInterface.Shared + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + 4.0 + + + + + + + + Code + + + + + + + + + {47da5933-bef8-4729-94e6-abde2db12262} + SafeExamBrowser.Contracts + + + + \ No newline at end of file diff --git a/SafeExamBrowser.UserInterface.Desktop/Utilities/IconResourceLoader.cs b/SafeExamBrowser.UserInterface.Shared/Utilities/IconResourceLoader.cs similarity index 90% rename from SafeExamBrowser.UserInterface.Desktop/Utilities/IconResourceLoader.cs rename to SafeExamBrowser.UserInterface.Shared/Utilities/IconResourceLoader.cs index b1191df5..2c783011 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Utilities/IconResourceLoader.cs +++ b/SafeExamBrowser.UserInterface.Shared/Utilities/IconResourceLoader.cs @@ -15,11 +15,11 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using SafeExamBrowser.Contracts.Core; -namespace SafeExamBrowser.UserInterface.Desktop.Utilities +namespace SafeExamBrowser.UserInterface.Shared.Utilities { - internal static class IconResourceLoader + public static class IconResourceLoader { - internal static UIElement Load(IIconResource resource) + public static UIElement Load(IIconResource resource) { try { diff --git a/SafeExamBrowser.UserInterface.Shared/Utilities/UrlRandomizer.cs b/SafeExamBrowser.UserInterface.Shared/Utilities/UrlRandomizer.cs new file mode 100644 index 00000000..591f27e1 --- /dev/null +++ b/SafeExamBrowser.UserInterface.Shared/Utilities/UrlRandomizer.cs @@ -0,0 +1,43 @@ +/* + * 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; +using System.Text; + +namespace SafeExamBrowser.UserInterface.Shared.Utilities +{ + public static class UrlRandomizer + { + private const string DIGITS = "0123456789"; + private const string LETTERS = "abcdefghijklmnopqrstuvwxyz"; + + public static string Randomize(string url) + { + var generator = new Random(); + var result = new StringBuilder(); + + foreach (var character in url) + { + if (Char.IsDigit(character)) + { + result.Append(DIGITS[generator.Next(DIGITS.Length)]); + } + else if (Char.IsLetter(character)) + { + result.Append(LETTERS[generator.Next(LETTERS.Length)]); + } + else + { + result.Append(character); + } + } + + return result.ToString(); + } + } +} diff --git a/SafeExamBrowser.UserInterface.Desktop/Utilities/VisualExtensions.cs b/SafeExamBrowser.UserInterface.Shared/Utilities/VisualExtensions.cs similarity index 85% rename from SafeExamBrowser.UserInterface.Desktop/Utilities/VisualExtensions.cs rename to SafeExamBrowser.UserInterface.Shared/Utilities/VisualExtensions.cs index 64490379..8ffe5c79 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Utilities/VisualExtensions.cs +++ b/SafeExamBrowser.UserInterface.Shared/Utilities/VisualExtensions.cs @@ -10,16 +10,16 @@ using System.Windows; using System.Windows.Interop; using System.Windows.Media; -namespace SafeExamBrowser.UserInterface.Desktop.Utilities +namespace SafeExamBrowser.UserInterface.Shared.Utilities { - internal static class VisualExtensions + public static class VisualExtensions { /// /// WPF works with device-independent pixels. This method is required to /// transform such values to their absolute, device-specific pixel value. /// Source: https://stackoverflow.com/questions/3286175/how-do-i-convert-a-wpf-size-to-physical-pixels /// - internal static Vector TransformToPhysical(this Visual visual, double x, double y) + public static Vector TransformToPhysical(this Visual visual, double x, double y) { Matrix transformToDevice; var source = PresentationSource.FromVisual(visual); diff --git a/SafeExamBrowser.UserInterface.Desktop/Utilities/XamlIconResource.cs b/SafeExamBrowser.UserInterface.Shared/Utilities/XamlIconResource.cs similarity index 83% rename from SafeExamBrowser.UserInterface.Desktop/Utilities/XamlIconResource.cs rename to SafeExamBrowser.UserInterface.Shared/Utilities/XamlIconResource.cs index 33ddbd7f..b4e29d85 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Utilities/XamlIconResource.cs +++ b/SafeExamBrowser.UserInterface.Shared/Utilities/XamlIconResource.cs @@ -9,9 +9,9 @@ using System; using SafeExamBrowser.Contracts.Core; -namespace SafeExamBrowser.UserInterface.Desktop.Utilities +namespace SafeExamBrowser.UserInterface.Shared.Utilities { - internal class XamlIconResource : IIconResource + public class XamlIconResource : IIconResource { public Uri Uri { get; private set; } public bool IsBitmapResource => false; diff --git a/SafeExamBrowser.sln b/SafeExamBrowser.sln index c586616c..a18e08a3 100644 --- a/SafeExamBrowser.sln +++ b/SafeExamBrowser.sln @@ -56,6 +56,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Configurati EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Mobile", "SafeExamBrowser.UserInterface.Mobile\SafeExamBrowser.UserInterface.Mobile.csproj", "{89BC24DD-FF31-496E-9816-A160B686A3D4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Shared", "SafeExamBrowser.UserInterface.Shared\SafeExamBrowser.UserInterface.Shared.csproj", "{38525928-87BA-4F8C-8010-4EB97BFAAE13}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -232,6 +234,14 @@ Global {89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|Any CPU.Build.0 = Release|Any CPU {89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|x86.ActiveCfg = Release|Any CPU {89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|x86.Build.0 = Release|Any CPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|x86.ActiveCfg = Debug|x86 + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|x86.Build.0 = Debug|x86 + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|Any CPU.Build.0 = Release|Any CPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|x86.ActiveCfg = Release|Any CPU + {38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE