Renamed EventController to RuntimeController, added F5 key handling to browser window / control and enhanced about window.
This commit is contained in:
parent
6861353b64
commit
12246bd0f5
15 changed files with 63 additions and 20 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
using System;
|
||||
using CefSharp.WinForms;
|
||||
using SafeExamBrowser.Browser.Handlers;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings;
|
||||
|
@ -70,6 +71,7 @@ namespace SafeExamBrowser.Browser
|
|||
TitleChanged += (o, args) => titleChanged?.Invoke(args.Title);
|
||||
|
||||
MenuHandler = new BrowserContextMenuHandler(settings, text);
|
||||
KeyboardHandler = new BrowserKeyboardHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ using CefSharp;
|
|||
using SafeExamBrowser.Contracts.I18n;
|
||||
using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings;
|
||||
|
||||
namespace SafeExamBrowser.Browser
|
||||
namespace SafeExamBrowser.Browser.Handlers
|
||||
{
|
||||
/// <remarks>
|
||||
/// See https://cefsharp.github.io/api/57.0.0/html/T_CefSharp_IContextMenuHandler.htm.
|
31
SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs
Normal file
31
SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.Forms;
|
||||
using CefSharp;
|
||||
|
||||
namespace SafeExamBrowser.Browser.Handlers
|
||||
{
|
||||
class BrowserKeyboardHandler : IKeyboardHandler
|
||||
{
|
||||
public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
|
||||
{
|
||||
if (type == KeyType.KeyUp && windowsKeyCode == (int) Keys.F5)
|
||||
{
|
||||
browserControl.Reload();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,11 +67,12 @@
|
|||
<Compile Include="BrowserApplicationController.cs" />
|
||||
<Compile Include="BrowserApplicationInfo.cs" />
|
||||
<Compile Include="BrowserApplicationInstance.cs" />
|
||||
<Compile Include="BrowserContextMenuHandler.cs" />
|
||||
<Compile Include="Handlers\BrowserContextMenuHandler.cs" />
|
||||
<Compile Include="BrowserControl.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BrowserIconResource.cs" />
|
||||
<Compile Include="Handlers\BrowserKeyboardHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace SafeExamBrowser.Contracts.Behaviour
|
||||
{
|
||||
public interface IEventController
|
||||
public interface IRuntimeController
|
||||
{
|
||||
/// <summary>
|
||||
/// Wires up the event handling, i.e. subscribes to all relevant application events.
|
|
@ -59,7 +59,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Behaviour\IApplicationController.cs" />
|
||||
<Compile Include="Behaviour\IEventController.cs" />
|
||||
<Compile Include="Behaviour\IRuntimeController.cs" />
|
||||
<Compile Include="Behaviour\INotificationController.cs" />
|
||||
<Compile Include="Behaviour\IOperation.cs" />
|
||||
<Compile Include="Configuration\IIconResource.cs" />
|
||||
|
|
|
@ -19,7 +19,7 @@ using SafeExamBrowser.Core.Behaviour;
|
|||
namespace SafeExamBrowser.Core.UnitTests.Behaviour
|
||||
{
|
||||
[TestClass]
|
||||
public class EventControllerTests
|
||||
public class RuntimeControllerTests
|
||||
{
|
||||
private Mock<ILogger> loggerMock;
|
||||
private Mock<IProcessMonitor> processMonitorMock;
|
||||
|
@ -27,7 +27,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour
|
|||
private Mock<IWindowMonitor> windowMonitorMock;
|
||||
private Mock<IWorkingArea> workingAreaMock;
|
||||
|
||||
private IEventController sut;
|
||||
private IRuntimeController sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
|
@ -38,7 +38,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour
|
|||
windowMonitorMock= new Mock<IWindowMonitor>();
|
||||
workingAreaMock = new Mock<IWorkingArea>();
|
||||
|
||||
sut = new EventController(
|
||||
sut = new RuntimeController(
|
||||
loggerMock.Object,
|
||||
processMonitorMock.Object,
|
||||
taskbarMock.Object,
|
|
@ -72,7 +72,7 @@
|
|||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Behaviour\EventControllerTests.cs" />
|
||||
<Compile Include="Behaviour\RuntimeControllerTests.cs" />
|
||||
<Compile Include="Behaviour\StartupControllerTests.cs" />
|
||||
<Compile Include="Behaviour\ShutdownControllerTests.cs" />
|
||||
<Compile Include="I18n\TextTests.cs" />
|
||||
|
|
|
@ -16,11 +16,11 @@ namespace SafeExamBrowser.Core.Behaviour.Operations
|
|||
public class EventControllerOperation : IOperation
|
||||
{
|
||||
private ILogger logger;
|
||||
private IEventController controller;
|
||||
private IRuntimeController controller;
|
||||
|
||||
public ISplashScreen SplashScreen { private get; set; }
|
||||
|
||||
public EventControllerOperation(IEventController controller, ILogger logger)
|
||||
public EventControllerOperation(IRuntimeController controller, ILogger logger)
|
||||
{
|
||||
this.controller = controller;
|
||||
this.logger = logger;
|
||||
|
|
|
@ -15,7 +15,7 @@ using SafeExamBrowser.Contracts.UserInterface;
|
|||
|
||||
namespace SafeExamBrowser.Core.Behaviour
|
||||
{
|
||||
public class EventController : IEventController
|
||||
public class RuntimeController : IRuntimeController
|
||||
{
|
||||
private ILogger logger;
|
||||
private IProcessMonitor processMonitor;
|
||||
|
@ -23,7 +23,7 @@ namespace SafeExamBrowser.Core.Behaviour
|
|||
private IWindowMonitor windowMonitor;
|
||||
private IWorkingArea workingArea;
|
||||
|
||||
public EventController(
|
||||
public RuntimeController(
|
||||
ILogger logger,
|
||||
IProcessMonitor processMonitor,
|
||||
ITaskbar taskbar,
|
|
@ -58,7 +58,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Behaviour\EventController.cs" />
|
||||
<Compile Include="Behaviour\RuntimeController.cs" />
|
||||
<Compile Include="Behaviour\Operations\BrowserOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\EventControllerOperation.cs" />
|
||||
<Compile Include="Behaviour\Operations\ProcessMonitorOperation.cs" />
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
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"
|
||||
Title="About Safe Exam Browser" Height="350" Width="450" ResizeMode="NoResize" Icon="./Images/SafeExamBrowser.ico"
|
||||
ShowInTaskbar="False" WindowStartupLocation="CenterScreen">
|
||||
<Window.Background>
|
||||
<SolidColorBrush Color="Black" Opacity="0.8" />
|
||||
|
@ -19,8 +19,8 @@
|
|||
<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" />
|
||||
<Image Grid.ColumnSpan="2" Source="pack://application:,,,/SafeExamBrowser.UserInterface;component/Images/SplashScreen.png" Margin="0,5,0,0" />
|
||||
<TextBlock x:Name="VersionInfo" Grid.Row="0" Grid.Column="1" Foreground="DarkGray" Margin="25,70,50,10" TextWrapping="Wrap" />
|
||||
<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
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace SafeExamBrowser.UserInterface
|
|||
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));
|
||||
VersionInfo.Inlines.Add(new Run(settings.ProgramCopyright) { FontSize = 10 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace SafeExamBrowser.UserInterface
|
|||
}
|
||||
|
||||
Closing += (o, args) => closing?.Invoke();
|
||||
KeyUp += BrowserWindow_KeyUp;
|
||||
UrlTextBox.KeyUp += UrlTextBox_KeyUp;
|
||||
ReloadButton.Click += (o, args) => ReloadRequested?.Invoke();
|
||||
BackButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
|
||||
|
@ -87,6 +88,14 @@ namespace SafeExamBrowser.UserInterface
|
|||
ApplySettings();
|
||||
}
|
||||
|
||||
private void BrowserWindow_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.F5)
|
||||
{
|
||||
ReloadRequested?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void UrlTextBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace SafeExamBrowser
|
|||
{
|
||||
private IApplicationController browserController;
|
||||
private IApplicationInfo browserInfo;
|
||||
private IEventController eventController;
|
||||
private IRuntimeController runtimeController;
|
||||
private ILogger logger;
|
||||
private INativeMethods nativeMethods;
|
||||
private IProcessMonitor processMonitor;
|
||||
|
@ -66,7 +66,7 @@ namespace SafeExamBrowser
|
|||
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
|
||||
workingArea = new WorkingArea(new ModuleLogger(logger, typeof(WorkingArea)), nativeMethods);
|
||||
|
||||
eventController = new EventController(new ModuleLogger(logger, typeof(EventController)), processMonitor, Taskbar, windowMonitor, workingArea);
|
||||
runtimeController = new RuntimeController(new ModuleLogger(logger, typeof(RuntimeController)), processMonitor, Taskbar, windowMonitor, workingArea);
|
||||
ShutdownController = new ShutdownController(logger, settings, text, uiFactory);
|
||||
StartupController = new StartupController(logger, settings, text, uiFactory);
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace SafeExamBrowser
|
|||
StartupOperations.Enqueue(new WorkingAreaOperation(logger, Taskbar, workingArea));
|
||||
StartupOperations.Enqueue(new TaskbarOperation(logger, settings, Taskbar, text, uiFactory));
|
||||
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
||||
StartupOperations.Enqueue(new EventControllerOperation(eventController, logger));
|
||||
StartupOperations.Enqueue(new EventControllerOperation(runtimeController, logger));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue