From 87f4ad8bf262ad3dd8a85309db83a64f1a98f4bb Mon Sep 17 00:00:00 2001 From: dbuechel Date: Thu, 25 Jan 2018 11:59:44 +0100 Subject: [PATCH] SEBWIN-219: Implemented draft of runtime window. --- SafeExamBrowser.Runtime/App.cs | 7 +-- SafeExamBrowser.Runtime/CompositionRoot.cs | 4 ++ .../RuntimeWindow.xaml | 56 +++++++++++++++++++ .../RuntimeWindow.xaml.cs | 45 +++++++++++++++ ...feExamBrowser.UserInterface.Classic.csproj | 7 +++ 5 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml create mode 100644 SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs diff --git a/SafeExamBrowser.Runtime/App.cs b/SafeExamBrowser.Runtime/App.cs index b4a8d348..65e98b1f 100644 --- a/SafeExamBrowser.Runtime/App.cs +++ b/SafeExamBrowser.Runtime/App.cs @@ -63,10 +63,9 @@ namespace SafeExamBrowser.Runtime if (success) { - // TODO: Probably needs new window to display status of running application... - //MainWindow = instances.SplashScreen; - //MainWindow.Closing += MainWindow_Closing; - //MainWindow.Show(); + MainWindow = instances.RuntimeWindow; + MainWindow.Closing += MainWindow_Closing; + MainWindow.Show(); } else { diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index 4f30f348..43389524 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -35,6 +35,7 @@ namespace SafeExamBrowser.Runtime internal IRuntimeController RuntimeController { get; private set; } internal Queue StartupOperations { get; private set; } + internal RuntimeWindow RuntimeWindow { get; private set; } internal void BuildObjectGraph() { @@ -56,6 +57,9 @@ namespace SafeExamBrowser.Runtime var startupController = new StartupController(logger, runtimeInfo, systemInfo, text, uiFactory); RuntimeController = new RuntimeController(serviceProxy, new ModuleLogger(logger, typeof(RuntimeController)), settingsRepository, shutdownController, startupController); + RuntimeWindow = new RuntimeWindow(new DefaultLogFormatter(), runtimeInfo); + + logger.Subscribe(RuntimeWindow); StartupOperations = new Queue(); StartupOperations.Enqueue(new I18nOperation(logger, text)); diff --git a/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml new file mode 100644 index 00000000..f5d1bed9 --- /dev/null +++ b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + 5 + + + + + + + diff --git a/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs new file mode 100644 index 00000000..21f7a232 --- /dev/null +++ b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 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.Documents; +using SafeExamBrowser.Contracts.Configuration; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.UserInterface.Classic +{ + public partial class RuntimeWindow : Window, ILogObserver + { + private ILogContentFormatter formatter; + private IRuntimeInfo runtimeInfo; + + public RuntimeWindow(ILogContentFormatter formatter, IRuntimeInfo runtimeInfo) + { + this.formatter = formatter; + this.runtimeInfo = runtimeInfo; + + InitializeComponent(); + InitializeRuntimeWindow(); + } + + public void Notify(ILogContent content) + { + LogTextBlock.Text += formatter.Format(content) + Environment.NewLine; + LogScrollViewer.ScrollToEnd(); + } + + private void InitializeRuntimeWindow() + { + InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); + InfoTextBlock.Inlines.Add(new LineBreak()); + InfoTextBlock.Inlines.Add(new LineBreak()); + InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); + } + } +} diff --git a/SafeExamBrowser.UserInterface.Classic/SafeExamBrowser.UserInterface.Classic.csproj b/SafeExamBrowser.UserInterface.Classic/SafeExamBrowser.UserInterface.Classic.csproj index 68faf27a..9a743f2c 100644 --- a/SafeExamBrowser.UserInterface.Classic/SafeExamBrowser.UserInterface.Classic.csproj +++ b/SafeExamBrowser.UserInterface.Classic/SafeExamBrowser.UserInterface.Classic.csproj @@ -105,6 +105,9 @@ LogWindow.xaml + + RuntimeWindow.xaml + SplashScreen.xaml @@ -219,6 +222,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile