SEBWIN-219: Started implementing kiosk mode operation.

This commit is contained in:
dbuechel 2018-01-26 12:33:36 +01:00
parent 87f4ad8bf2
commit b22093e6a2
12 changed files with 147 additions and 33 deletions

View file

@ -25,6 +25,7 @@ namespace SafeExamBrowser.Contracts.I18n
MessageBox_StartupErrorTitle,
Notification_AboutTooltip,
Notification_LogTooltip,
RuntimeWindow_ApplicationRunning,
SplashScreen_CloseServiceConnection,
SplashScreen_EmptyClipboard,
SplashScreen_InitializeBrowser,

View file

@ -108,6 +108,7 @@
<Compile Include="UserInterface\IBrowserControl.cs" />
<Compile Include="UserInterface\IBrowserWindow.cs" />
<Compile Include="UserInterface\IMessageBox.cs" />
<Compile Include="UserInterface\IRuntimeWindow.cs" />
<Compile Include="UserInterface\MessageBoxResult.cs" />
<Compile Include="UserInterface\Taskbar\INotificationButton.cs" />
<Compile Include="UserInterface\ISplashScreen.cs" />

View file

@ -0,0 +1,21 @@
/*
* 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 SafeExamBrowser.Contracts.I18n;
namespace SafeExamBrowser.Contracts.UserInterface
{
public interface IRuntimeWindow : IWindow
{
/// <summary>
/// Updates the status text of the runtime window. If the busy flag is set,
/// the window will show an animation to indicate a long-running operation.
/// </summary>
void UpdateStatus(TextKey key);
}
}

View file

@ -30,6 +30,9 @@
<Entry key="Notification_LogTooltip">
Application Log
</Entry>
<Entry key="RuntimeWindow_ApplicationRunning">
The application is running.
</Entry>
<Entry key="SplashScreen_CloseServiceConnection">
Closing service connection
</Entry>

View file

@ -0,0 +1,22 @@
/*
* 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 Microsoft.VisualStudio.TestTools.UnitTesting;
namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{
[TestClass]
public class KioskModeOperationTests
{
[TestMethod]
public void Todo()
{
Assert.Fail();
}
}
}

View file

@ -81,6 +81,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Behaviour\Operations\ConfigurationOperationTests.cs" />
<Compile Include="Behaviour\Operations\KioskModeOperationTests.cs" />
<Compile Include="Behaviour\Operations\ServiceOperationTests.cs" />
<Compile Include="Behaviour\RuntimeControllerTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View file

@ -0,0 +1,30 @@
/*
* 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 SafeExamBrowser.Contracts.Behaviour;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Runtime.Behaviour.Operations
{
internal class KioskModeOperation : IOperation
{
public bool AbortStartup { get; private set; }
public ISplashScreen SplashScreen { private get; set; }
public void Perform()
{
// TODO
}
public void Revert()
{
// TODO
}
}
}

View file

@ -11,7 +11,9 @@ using System.Linq;
using SafeExamBrowser.Contracts.Behaviour;
using SafeExamBrowser.Contracts.Communication;
using SafeExamBrowser.Contracts.Configuration.Settings;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Runtime.Behaviour
{
@ -20,6 +22,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
private ICommunication serviceProxy;
private Queue<IOperation> operations;
private ILogger logger;
private IRuntimeWindow runtimeWindow;
private ISettingsRepository settingsRepository;
private IShutdownController shutdownController;
private IStartupController startupController;
@ -29,12 +32,14 @@ namespace SafeExamBrowser.Runtime.Behaviour
public RuntimeController(
ICommunication serviceProxy,
ILogger logger,
IRuntimeWindow runtimeWindow,
ISettingsRepository settingsRepository,
IShutdownController shutdownController,
IStartupController startupController)
{
this.serviceProxy = serviceProxy;
this.logger = logger;
this.runtimeWindow = runtimeWindow;
this.settingsRepository = settingsRepository;
this.shutdownController = shutdownController;
this.startupController = startupController;
@ -66,6 +71,8 @@ namespace SafeExamBrowser.Runtime.Behaviour
{
logger.Info("Starting event handling...");
// TODO SplashScreen.UpdateText(TextKey.SplashScreen_StartEventHandling);
runtimeWindow.UpdateStatus(TextKey.RuntimeWindow_ApplicationRunning);
}
private void Stop()

View file

@ -56,8 +56,8 @@ namespace SafeExamBrowser.Runtime
var shutdownController = new ShutdownController(logger, runtimeInfo, text, uiFactory);
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);
RuntimeWindow = new RuntimeWindow(new DefaultLogFormatter(), runtimeInfo, text);
RuntimeController = new RuntimeController(serviceProxy, new ModuleLogger(logger, typeof(RuntimeController)), RuntimeWindow, settingsRepository, shutdownController, startupController);
logger.Subscribe(RuntimeWindow);
@ -65,7 +65,7 @@ namespace SafeExamBrowser.Runtime
StartupOperations.Enqueue(new I18nOperation(logger, text));
StartupOperations.Enqueue(new ConfigurationOperation(logger, runtimeInfo, settingsRepository, text, uiFactory, args));
StartupOperations.Enqueue(new ServiceOperation(logger, serviceProxy, settingsRepository, text));
//StartupOperations.Enqueue(new KioskModeOperation());
StartupOperations.Enqueue(new KioskModeOperation());
}
internal void LogStartupInformation()

View file

@ -88,6 +88,7 @@
<ItemGroup>
<Compile Include="App.cs" />
<Compile Include="Behaviour\Operations\ConfigurationOperation.cs" />
<Compile Include="Behaviour\Operations\KioskModeOperation.cs" />
<Compile Include="Behaviour\Operations\ServiceOperation.cs" />
<Compile Include="CompositionRoot.cs" />
<Compile Include="Properties\AssemblyInfo.cs">

View file

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Classic"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" Background="White" Foreground="White" Height="500" Width="750" WindowStyle="None" WindowStartupLocation="CenterScreen"
Icon="./Images/SafeExamBrowser.ico" ResizeMode="NoResize" Title="RuntimeWindow" Topmost="True">
Icon="./Images/SafeExamBrowser.ico" ResizeMode="NoResize" Title="Safe Exam Browser" Topmost="True">
<Grid>
<Border Panel.ZIndex="10" BorderBrush="DodgerBlue" BorderThickness="5">
<Border.Effect>
@ -26,31 +26,33 @@
</Style>
</Border.Style>
</Border>
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="25" />
<RowDefinition Height="3*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="350" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Grid.ColumnSpan="2" Margin="-25,0,0,0" Source="pack://application:,,,/SafeExamBrowser.UserInterface.Classic;component/Images/SplashScreen.png" />
<TextBlock x:Name="InfoTextBlock" Grid.Column="1" Foreground="Gray" Margin="10,75,175,10" TextWrapping="Wrap" />
<Border BorderBrush="DodgerBlue" BorderThickness="1">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="25" />
<RowDefinition Height="3*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="350" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Grid.ColumnSpan="2" Margin="-25,0,0,0" Source="pack://application:,,,/SafeExamBrowser.UserInterface.Classic;component/Images/SplashScreen.png" />
<TextBlock x:Name="InfoTextBlock" Grid.Column="1" Foreground="Gray" Margin="10,75,175,10" TextWrapping="Wrap" />
</Grid>
<!--<ProgressBar x:Name="ProgressBar" Grid.Row="1" IsIndeterminate="True" BorderThickness="0" />-->
<TextBlock x:Name="StatusTextBlock" Grid.Row="1" Text="Application is running..." FontSize="12" FontWeight="Bold" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Border Grid.Row="2" BorderBrush="DodgerBlue" BorderThickness="0,0.5,0,0">
<ScrollViewer x:Name="LogScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,10,0,0">
<ScrollViewer.Resources>
<s:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">5</s:Double>
<s:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">5</s:Double>
</ScrollViewer.Resources>
<TextBox x:Name="LogTextBlock" Background="Transparent" BorderThickness="0" FontFamily="Courier New" Foreground="Black" IsReadOnly="True" />
</ScrollViewer>
</Border>
</Grid>
<!--<ProgressBar x:Name="ProgressBar" Grid.Row="1" IsIndeterminate="True" BorderThickness="0" />-->
<TextBlock x:Name="StatusTextBlock" Grid.Row="1" Text="Application is running..." FontSize="12" FontWeight="Bold" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Border Grid.Row="2" BorderBrush="DodgerBlue" BorderThickness="0,0.5,0,0">
<ScrollViewer x:Name="LogScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,10,0,0">
<ScrollViewer.Resources>
<s:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">5</s:Double>
<s:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">5</s:Double>
</ScrollViewer.Resources>
<TextBox x:Name="LogTextBlock" Background="Transparent" BorderThickness="0" FontFamily="Courier New" Foreground="Black" IsReadOnly="True" />
</ScrollViewer>
</Border>
</Grid>
</Border>
</Grid>
</Window>

View file

@ -10,32 +10,57 @@ using System;
using System.Windows;
using System.Windows.Documents;
using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.UserInterface.Classic
{
public partial class RuntimeWindow : Window, ILogObserver
public partial class RuntimeWindow : Window, ILogObserver, IRuntimeWindow
{
private ILogContentFormatter formatter;
private IRuntimeInfo runtimeInfo;
private IText text;
private WindowClosingEventHandler closing;
public RuntimeWindow(ILogContentFormatter formatter, IRuntimeInfo runtimeInfo)
event WindowClosingEventHandler IWindow.Closing
{
add { closing += value; }
remove { closing -= value; }
}
public RuntimeWindow(ILogContentFormatter formatter, IRuntimeInfo runtimeInfo, IText text)
{
this.formatter = formatter;
this.runtimeInfo = runtimeInfo;
this.text = text;
InitializeComponent();
InitializeRuntimeWindow();
}
public void BringToForeground()
{
Dispatcher.Invoke(Activate);
}
public void Notify(ILogContent content)
{
LogTextBlock.Text += formatter.Format(content) + Environment.NewLine;
LogScrollViewer.ScrollToEnd();
Dispatcher.Invoke(() =>
{
LogTextBlock.Text += formatter.Format(content) + Environment.NewLine;
LogScrollViewer.ScrollToEnd();
});
}
public void UpdateStatus(TextKey key)
{
Dispatcher.Invoke(() => StatusTextBlock.Text = text.Get(key));
}
private void InitializeRuntimeWindow()
{
Title = $"{runtimeInfo.ProgramTitle} - Version {runtimeInfo.ProgramVersion}";
InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new LineBreak());