Implemented draft of the about window.
This commit is contained in:
parent
75f104f136
commit
6861353b64
13 changed files with 193 additions and 12 deletions
|
@ -60,8 +60,6 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AboutNotificationIconResource.cs" />
|
|
||||||
<Compile Include="AboutNotificationInfo.cs" />
|
|
||||||
<Compile Include="Settings\BrowserSettings.cs" />
|
<Compile Include="Settings\BrowserSettings.cs" />
|
||||||
<Compile Include="Settings\SettingsImpl.cs" />
|
<Compile Include="Settings\SettingsImpl.cs" />
|
||||||
<Compile Include="WorkingArea.cs" />
|
<Compile Include="WorkingArea.cs" />
|
||||||
|
|
|
@ -16,5 +16,10 @@ namespace SafeExamBrowser.Contracts.Behaviour
|
||||||
/// Registers the taskbar notification.
|
/// Registers the taskbar notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void RegisterNotification(ITaskbarNotification notification);
|
void RegisterNotification(ITaskbarNotification notification);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instructs the controller to shut down and release all used resources.
|
||||||
|
/// </summary>
|
||||||
|
void Terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ namespace SafeExamBrowser.Contracts.UserInterface
|
||||||
{
|
{
|
||||||
public interface IUserInterfaceFactory : IMessageBox
|
public interface IUserInterfaceFactory : IMessageBox
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new about window displaying information about the currently running application version.
|
||||||
|
/// </summary>
|
||||||
|
IWindow CreateAboutWindow(ISettings settings, IText text);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a taskbar button, initialized with the given application information.
|
/// Creates a taskbar button, initialized with the given application information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -7,27 +7,31 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Behaviour;
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
using SafeExamBrowser.Contracts.I18n;
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.UserInterface;
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
using SafeExamBrowser.Core.Notifications;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Core.Behaviour.Operations
|
namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||||
{
|
{
|
||||||
public class TaskbarOperation : IOperation
|
public class TaskbarOperation : IOperation
|
||||||
{
|
{
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
|
private INotificationController aboutController;
|
||||||
private ITaskbar taskbar;
|
private ITaskbar taskbar;
|
||||||
private IUserInterfaceFactory uiFactory;
|
private IUserInterfaceFactory uiFactory;
|
||||||
private INotificationInfo aboutInfo;
|
private IText text;
|
||||||
|
private ISettings settings;
|
||||||
|
|
||||||
public ISplashScreen SplashScreen { private get; set; }
|
public ISplashScreen SplashScreen { private get; set; }
|
||||||
|
|
||||||
public TaskbarOperation(ILogger logger, INotificationInfo aboutInfo, ITaskbar taskbar, IUserInterfaceFactory uiFactory)
|
public TaskbarOperation(ILogger logger, ISettings settings, ITaskbar taskbar, IText text, IUserInterfaceFactory uiFactory)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.aboutInfo = aboutInfo;
|
this.settings = settings;
|
||||||
this.taskbar = taskbar;
|
this.taskbar = taskbar;
|
||||||
|
this.text = text;
|
||||||
this.uiFactory = uiFactory;
|
this.uiFactory = uiFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,14 +40,18 @@ namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||||
logger.Info("Initializing taskbar...");
|
logger.Info("Initializing taskbar...");
|
||||||
SplashScreen.UpdateText(Key.SplashScreen_InitializeTaskbar);
|
SplashScreen.UpdateText(Key.SplashScreen_InitializeTaskbar);
|
||||||
|
|
||||||
|
var aboutInfo = new AboutNotificationInfo(text);
|
||||||
var aboutNotification = uiFactory.CreateNotification(aboutInfo);
|
var aboutNotification = uiFactory.CreateNotification(aboutInfo);
|
||||||
|
|
||||||
|
aboutController = new AboutNotificationController(settings, text, uiFactory);
|
||||||
|
aboutController.RegisterNotification(aboutNotification);
|
||||||
|
|
||||||
taskbar.AddNotification(aboutNotification);
|
taskbar.AddNotification(aboutNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Revert()
|
public void Revert()
|
||||||
{
|
{
|
||||||
// Nothing to do here so far...
|
aboutController.Terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 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.Configuration.Settings;
|
||||||
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Core.Notifications
|
||||||
|
{
|
||||||
|
public class AboutNotificationController : INotificationController
|
||||||
|
{
|
||||||
|
private ITaskbarNotification notification;
|
||||||
|
private ISettings settings;
|
||||||
|
private IText text;
|
||||||
|
private IUserInterfaceFactory uiFactory;
|
||||||
|
private IWindow window;
|
||||||
|
|
||||||
|
public AboutNotificationController(ISettings settings, IText text, IUserInterfaceFactory uiFactory)
|
||||||
|
{
|
||||||
|
this.settings = settings;
|
||||||
|
this.text = text;
|
||||||
|
this.uiFactory = uiFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterNotification(ITaskbarNotification notification)
|
||||||
|
{
|
||||||
|
this.notification = notification;
|
||||||
|
|
||||||
|
notification.Clicked += Notification_Clicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Terminate()
|
||||||
|
{
|
||||||
|
window?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Notification_Clicked()
|
||||||
|
{
|
||||||
|
if (window == null)
|
||||||
|
{
|
||||||
|
window = uiFactory.CreateAboutWindow(settings, text);
|
||||||
|
|
||||||
|
window.Closing += () => window = null;
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.BringToForeground();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
using System;
|
using System;
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
namespace SafeExamBrowser.Core.Notifications
|
||||||
{
|
{
|
||||||
public class AboutNotificationIconResource : IIconResource
|
public class AboutNotificationIconResource : IIconResource
|
||||||
{
|
{
|
|
@ -9,7 +9,7 @@
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
using SafeExamBrowser.Contracts.I18n;
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
namespace SafeExamBrowser.Core.Notifications
|
||||||
{
|
{
|
||||||
public class AboutNotificationInfo : INotificationInfo
|
public class AboutNotificationInfo : INotificationInfo
|
||||||
{
|
{
|
|
@ -75,6 +75,9 @@
|
||||||
<Compile Include="Logging\LogText.cs" />
|
<Compile Include="Logging\LogText.cs" />
|
||||||
<Compile Include="Logging\ModuleLogger.cs" />
|
<Compile Include="Logging\ModuleLogger.cs" />
|
||||||
<Compile Include="Logging\ThreadInfo.cs" />
|
<Compile Include="Logging\ThreadInfo.cs" />
|
||||||
|
<Compile Include="Notifications\AboutNotificationController.cs" />
|
||||||
|
<Compile Include="Notifications\AboutNotificationIconResource.cs" />
|
||||||
|
<Compile Include="Notifications\AboutNotificationInfo.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
41
SafeExamBrowser.UserInterface/AboutWindow.xaml
Normal file
41
SafeExamBrowser.UserInterface/AboutWindow.xaml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<Window x:Class="SafeExamBrowser.UserInterface.AboutWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
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:local="clr-namespace:SafeExamBrowser.UserInterface"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="About" Height="350" Width="450" ResizeMode="NoResize" Icon="./Images/SafeExamBrowser.ico"
|
||||||
|
ShowInTaskbar="False" WindowStartupLocation="CenterScreen">
|
||||||
|
<Window.Background>
|
||||||
|
<SolidColorBrush Color="Black" Opacity="0.8" />
|
||||||
|
</Window.Background>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Image Grid.ColumnSpan="2" Source="pack://application:,,,/SafeExamBrowser.UserInterface;component/Images/SplashScreen.png" />
|
||||||
|
<TextBlock x:Name="VersionInfo" Grid.Row="0" Grid.Column="1" Foreground="White" Margin="50,75,35,10" TextWrapping="Wrap" FontSize="10" />
|
||||||
|
<ScrollViewer Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" VerticalScrollBarVisibility="Auto">
|
||||||
|
<TextBlock x:Name="MainText" Foreground="White" Margin="10" FontSize="10" TextWrapping="Wrap">
|
||||||
|
This application is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||||
|
with this application, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
<LineBreak />
|
||||||
|
<LineBreak />
|
||||||
|
<Bold><Underline>CefSharp (.NET bindings for the Chromium Embedded Framework)</Underline></Bold>
|
||||||
|
<LineBreak />
|
||||||
|
Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
|
||||||
|
<LineBreak />
|
||||||
|
<LineBreak />
|
||||||
|
<Bold><Underline>CEF (Chromium Embedded Framework)</Underline></Bold>
|
||||||
|
<LineBreak />
|
||||||
|
Copyright © 2008-2014 Marshall A. Greenblatt. Portions Copyright © 2006-2009 Google Inc. All rights reserved.
|
||||||
|
</TextBlock>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
52
SafeExamBrowser.UserInterface/AboutWindow.xaml.cs
Normal file
52
SafeExamBrowser.UserInterface/AboutWindow.xaml.cs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 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.Documents;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.UserInterface
|
||||||
|
{
|
||||||
|
public partial class AboutWindow : Window, IWindow
|
||||||
|
{
|
||||||
|
private ISettings settings;
|
||||||
|
private IText text;
|
||||||
|
private WindowClosingEventHandler closing;
|
||||||
|
|
||||||
|
event WindowClosingEventHandler IWindow.Closing
|
||||||
|
{
|
||||||
|
add { closing += value; }
|
||||||
|
remove { closing -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public AboutWindow(ISettings settings, IText text)
|
||||||
|
{
|
||||||
|
this.settings = settings;
|
||||||
|
this.text = text;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
InitializeAboutWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BringToForeground()
|
||||||
|
{
|
||||||
|
Activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeAboutWindow()
|
||||||
|
{
|
||||||
|
Closing += (o, args) => closing?.Invoke();
|
||||||
|
VersionInfo.Inlines.Add(new Run($"{text.Get(Key.Version)} {settings.ProgramVersion}") { FontStyle = FontStyles.Italic });
|
||||||
|
VersionInfo.Inlines.Add(new LineBreak());
|
||||||
|
VersionInfo.Inlines.Add(new LineBreak());
|
||||||
|
VersionInfo.Inlines.Add(new Run(settings.ProgramCopyright));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,6 +67,9 @@
|
||||||
<Reference Include="WindowsFormsIntegration" />
|
<Reference Include="WindowsFormsIntegration" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AboutWindow.xaml.cs">
|
||||||
|
<DependentUpon>AboutWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="BrowserWindow.xaml.cs">
|
<Compile Include="BrowserWindow.xaml.cs">
|
||||||
<DependentUpon>BrowserWindow.xaml</DependentUpon>
|
<DependentUpon>BrowserWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -118,6 +121,10 @@
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Page Include="AboutWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="BrowserWindow.xaml">
|
<Page Include="BrowserWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|
|
@ -18,6 +18,11 @@ namespace SafeExamBrowser.UserInterface
|
||||||
{
|
{
|
||||||
public class UserInterfaceFactory : IUserInterfaceFactory
|
public class UserInterfaceFactory : IUserInterfaceFactory
|
||||||
{
|
{
|
||||||
|
public IWindow CreateAboutWindow(ISettings settings, IText text)
|
||||||
|
{
|
||||||
|
return new AboutWindow(settings, text);
|
||||||
|
}
|
||||||
|
|
||||||
public ITaskbarButton CreateApplicationButton(IApplicationInfo info)
|
public ITaskbarButton CreateApplicationButton(IApplicationInfo info)
|
||||||
{
|
{
|
||||||
return new ApplicationButton(info);
|
return new ApplicationButton(info);
|
||||||
|
|
|
@ -35,7 +35,6 @@ namespace SafeExamBrowser
|
||||||
private IEventController eventController;
|
private IEventController eventController;
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
private INotificationInfo aboutInfo;
|
|
||||||
private IProcessMonitor processMonitor;
|
private IProcessMonitor processMonitor;
|
||||||
private ISettings settings;
|
private ISettings settings;
|
||||||
private IText text;
|
private IText text;
|
||||||
|
@ -62,7 +61,6 @@ namespace SafeExamBrowser
|
||||||
logger.Subscribe(new LogFileWriter(settings));
|
logger.Subscribe(new LogFileWriter(settings));
|
||||||
|
|
||||||
text = new Text(textResource);
|
text = new Text(textResource);
|
||||||
aboutInfo = new AboutNotificationInfo(text);
|
|
||||||
browserController = new BrowserApplicationController(settings, text, uiFactory);
|
browserController = new BrowserApplicationController(settings, text, uiFactory);
|
||||||
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)), nativeMethods);
|
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)), nativeMethods);
|
||||||
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
|
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
|
||||||
|
@ -76,7 +74,7 @@ namespace SafeExamBrowser
|
||||||
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
|
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
|
||||||
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
|
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
|
||||||
StartupOperations.Enqueue(new WorkingAreaOperation(logger, Taskbar, workingArea));
|
StartupOperations.Enqueue(new WorkingAreaOperation(logger, Taskbar, workingArea));
|
||||||
StartupOperations.Enqueue(new TaskbarOperation(logger, aboutInfo, Taskbar, uiFactory));
|
StartupOperations.Enqueue(new TaskbarOperation(logger, settings, Taskbar, text, uiFactory));
|
||||||
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
||||||
StartupOperations.Enqueue(new EventControllerOperation(eventController, logger));
|
StartupOperations.Enqueue(new EventControllerOperation(eventController, logger));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue