From 32cecbd5e20024e6fc2acaa106010f3cb0b7a42c Mon Sep 17 00:00:00 2001 From: dbuechel Date: Wed, 9 Jan 2019 11:17:43 +0100 Subject: [PATCH] SEBWIN-104: Revived the about window and overhauled taskbar layout. --- .../Operations/TaskbarOperationTests.cs | 6 +++ SafeExamBrowser.Client/CompositionRoot.cs | 4 +- .../AboutNotificationIconResource.cs | 6 +-- .../Operations/TaskbarOperation.cs | 38 ++++++++++++++----- .../PowerSupply.cs | 2 +- .../AboutWindow.xaml | 10 ++--- .../Controls/KeyboardLayoutControl.xaml | 25 ++++++++---- .../Controls/KeyboardLayoutControl.xaml.cs | 2 +- .../Controls/NotificationButton.xaml | 2 +- .../Controls/PowerSupplyControl.xaml | 2 +- .../Controls/WirelessNetworkControl.xaml | 2 +- .../Images/AboutNotification.xaml | 8 ++++ ...feExamBrowser.UserInterface.Classic.csproj | 4 ++ .../Taskbar.xaml | 6 +-- .../UserInterfaceFactory.cs | 11 ++++++ .../ViewModels/LogViewModel.cs | 2 +- 16 files changed, 94 insertions(+), 36 deletions(-) create mode 100644 SafeExamBrowser.UserInterface.Classic/Images/AboutNotification.xaml diff --git a/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs index 7c7a954c..c15da471 100644 --- a/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs @@ -25,6 +25,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations { private Mock loggerMock; private TaskbarSettings settings; + private Mock aboutInfoMock; + private Mock aboutControllerMock; private Mock logInfoMock; private Mock logControllerMock; private Mock> keyboardLayoutMock; @@ -41,6 +43,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations public void Initialize() { loggerMock = new Mock(); + aboutInfoMock = new Mock(); + aboutControllerMock = new Mock(); logInfoMock = new Mock(); logControllerMock = new Mock(); keyboardLayoutMock = new Mock>(); @@ -60,6 +64,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations sut = new TaskbarOperation( loggerMock.Object, + aboutInfoMock.Object, + aboutControllerMock.Object, logInfoMock.Object, logControllerMock.Object, keyboardLayoutMock.Object, diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs index 9db0b7c8..56983839 100644 --- a/SafeExamBrowser.Client/CompositionRoot.cs +++ b/SafeExamBrowser.Client/CompositionRoot.cs @@ -223,12 +223,14 @@ namespace SafeExamBrowser.Client private IOperation BuildTaskbarOperation() { + var aboutInfo = new AboutNotificationInfo(text); + var aboutController = new AboutNotificationController(configuration.AppConfig, uiFactory); var keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, nameof(KeyboardLayout)), text); var logController = new LogNotificationController(logger, uiFactory); var logInfo = new LogNotificationInfo(text); var powerSupply = new PowerSupply(new ModuleLogger(logger, nameof(PowerSupply)), text); var wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, nameof(WirelessNetwork)), text); - var operation = new TaskbarOperation(logger, logInfo, logController, keyboardLayout, powerSupply, wirelessNetwork, systemInfo, Taskbar, configuration.Settings.Taskbar, text, uiFactory); + var operation = new TaskbarOperation(logger, aboutInfo, aboutController, logInfo, logController, keyboardLayout, powerSupply, wirelessNetwork, systemInfo, Taskbar, configuration.Settings.Taskbar, text, uiFactory); return operation; } diff --git a/SafeExamBrowser.Client/Notifications/AboutNotificationIconResource.cs b/SafeExamBrowser.Client/Notifications/AboutNotificationIconResource.cs index b024ce30..c162f880 100644 --- a/SafeExamBrowser.Client/Notifications/AboutNotificationIconResource.cs +++ b/SafeExamBrowser.Client/Notifications/AboutNotificationIconResource.cs @@ -13,8 +13,8 @@ namespace SafeExamBrowser.Client.Notifications { internal class AboutNotificationIconResource : IIconResource { - public Uri Uri => new Uri("pack://application:,,,/SafeExamBrowser;component/SafeExamBrowser.ico"); - public bool IsBitmapResource => true; - public bool IsXamlResource => false; + public Uri Uri => new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Classic;component/Images/AboutNotification.xaml"); + public bool IsBitmapResource => false; + public bool IsXamlResource => true; } } diff --git a/SafeExamBrowser.Client/Operations/TaskbarOperation.cs b/SafeExamBrowser.Client/Operations/TaskbarOperation.cs index cbd2da9b..19f44bb4 100644 --- a/SafeExamBrowser.Client/Operations/TaskbarOperation.cs +++ b/SafeExamBrowser.Client/Operations/TaskbarOperation.cs @@ -22,6 +22,8 @@ namespace SafeExamBrowser.Client.Operations internal class TaskbarOperation : IOperation { private ILogger logger; + private INotificationInfo aboutInfo; + private INotificationController aboutController; private INotificationInfo logInfo; private INotificationController logController; private TaskbarSettings settings; @@ -38,6 +40,8 @@ namespace SafeExamBrowser.Client.Operations public TaskbarOperation( ILogger logger, + INotificationInfo aboutInfo, + INotificationController aboutController, INotificationInfo logInfo, INotificationController logController, ISystemComponent keyboardLayout, @@ -49,6 +53,8 @@ namespace SafeExamBrowser.Client.Operations IText text, IUserInterfaceFactory uiFactory) { + this.aboutInfo = aboutInfo; + this.aboutController = aboutController; this.logger = logger; this.logInfo = logInfo; this.logController = logController; @@ -67,6 +73,8 @@ namespace SafeExamBrowser.Client.Operations logger.Info("Initializing taskbar..."); StatusChanged?.Invoke(TextKey.OperationStatus_InitializeTaskbar); + AddAboutNotification(); + if (settings.AllowApplicationLog) { CreateLogNotification(); @@ -77,16 +85,16 @@ namespace SafeExamBrowser.Client.Operations AddKeyboardLayoutControl(); } - if (systemInfo.HasBattery) - { - AddPowerSupplyControl(); - } - if (settings.AllowWirelessNetwork) { AddWirelessNetworkControl(); } + if (systemInfo.HasBattery) + { + AddPowerSupplyControl(); + } + return OperationResult.Success; } @@ -95,6 +103,8 @@ namespace SafeExamBrowser.Client.Operations logger.Info("Terminating taskbar..."); StatusChanged?.Invoke(TextKey.OperationStatus_TerminateTaskbar); + aboutController.Terminate(); + if (settings.AllowApplicationLog) { logController.Terminate(); @@ -105,19 +115,27 @@ namespace SafeExamBrowser.Client.Operations keyboardLayout.Terminate(); } - if (systemInfo.HasBattery) - { - powerSupply.Terminate(); - } - if (settings.AllowWirelessNetwork) { wirelessNetwork.Terminate(); } + if (systemInfo.HasBattery) + { + powerSupply.Terminate(); + } + return OperationResult.Success; } + private void AddAboutNotification() + { + var aboutNotification = uiFactory.CreateNotification(aboutInfo); + + aboutController.RegisterNotification(aboutNotification); + taskbar.AddNotification(aboutNotification); + } + private void AddKeyboardLayoutControl() { var control = uiFactory.CreateKeyboardLayoutControl(); diff --git a/SafeExamBrowser.SystemComponents/PowerSupply.cs b/SafeExamBrowser.SystemComponents/PowerSupply.cs index 450e3d5c..b4704432 100644 --- a/SafeExamBrowser.SystemComponents/PowerSupply.cs +++ b/SafeExamBrowser.SystemComponents/PowerSupply.cs @@ -63,7 +63,7 @@ namespace SafeExamBrowser.SystemComponents { var charge = SystemInformation.PowerStatus.BatteryLifePercent; var percentage = Math.Round(charge * 100); - var status = charge <= 0.35 ? (charge <= 0.2 ? BatteryChargeStatus.Critical : BatteryChargeStatus.Low) : BatteryChargeStatus.Okay; + var status = charge <= 0.4 ? (charge <= 0.2 ? BatteryChargeStatus.Critical : BatteryChargeStatus.Low) : BatteryChargeStatus.Okay; var online = SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online; var tooltip = string.Empty; diff --git a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml index 5bdc23cf..ec76c581 100644 --- a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml +++ b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml @@ -5,19 +5,19 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Classic" mc:Ignorable="d" - Title="About Safe Exam Browser" Background="White" Height="350" Width="450" ResizeMode="NoResize" Icon="./Images/SafeExamBrowser.ico" + Title="Version & License Information" Background="White" Height="325" Width="600" ResizeMode="NoResize" Icon="./Images/SafeExamBrowser.ico" ShowInTaskbar="False" WindowStartupLocation="CenterScreen"> - - + + - + This application is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed @@ -26,7 +26,7 @@ CefSharp (.NET bindings for the Chromium Embedded Framework) - Copyright © 2010-2017 The CefSharp Authors. All rights reserved. + Copyright © 2010-2019 The CefSharp Authors. All rights reserved. CEF (Chromium Embedded Framework) diff --git a/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml b/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml index f1a96092..7e0d3017 100644 --- a/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml +++ b/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Classic.Controls" mc:Ignorable="d" d:DesignHeight="40" d:DesignWidth="40"> @@ -25,15 +26,23 @@ - diff --git a/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml.cs index 9c2cb3a7..a82aead3 100644 --- a/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/Controls/KeyboardLayoutControl.xaml.cs @@ -80,7 +80,7 @@ namespace SafeExamBrowser.UserInterface.Classic.Controls private void SetCurrent(KeyboardLayoutButton button, IKeyboardLayout layout) { - var name = layout.Name?.Length > 3 ? String.Join(string.Empty, layout.Name.Split(' ').Select(s => s.First())) : layout.Name; + var name = layout.Name?.Length > 3 ? String.Join(string.Empty, layout.Name.Split(' ').Where(s => Char.IsLetter(s.First())).Select(s => s.First())) : layout.Name; foreach (var child in LayoutsStackPanel.Children) { diff --git a/SafeExamBrowser.UserInterface.Classic/Controls/NotificationButton.xaml b/SafeExamBrowser.UserInterface.Classic/Controls/NotificationButton.xaml index 6bb26dfc..da1bfcea 100644 --- a/SafeExamBrowser.UserInterface.Classic/Controls/NotificationButton.xaml +++ b/SafeExamBrowser.UserInterface.Classic/Controls/NotificationButton.xaml @@ -14,6 +14,6 @@ -