SEBWIN-219: Extracted message box from UI factory and tidied up user interface contracts.
This commit is contained in:
parent
6334294e4d
commit
49d9b03d7a
37 changed files with 183 additions and 185 deletions
|
@ -18,6 +18,7 @@ using SafeExamBrowser.Contracts.Configuration;
|
|||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.BrowserSettings;
|
||||
|
||||
|
@ -29,6 +30,7 @@ namespace SafeExamBrowser.Browser
|
|||
private IList<IApplicationInstance> instances = new List<IApplicationInstance>();
|
||||
private BrowserSettings settings;
|
||||
private ILogger logger;
|
||||
private IMessageBox messageBox;
|
||||
private IRuntimeProxy runtime;
|
||||
private RuntimeInfo runtimeInfo;
|
||||
private IUserInterfaceFactory uiFactory;
|
||||
|
@ -38,11 +40,13 @@ namespace SafeExamBrowser.Browser
|
|||
BrowserSettings settings,
|
||||
RuntimeInfo runtimeInfo,
|
||||
ILogger logger,
|
||||
IMessageBox messageBox,
|
||||
IRuntimeProxy runtime,
|
||||
IText text,
|
||||
IUserInterfaceFactory uiFactory)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.messageBox = messageBox;
|
||||
this.runtime = runtime;
|
||||
this.runtimeInfo = runtimeInfo;
|
||||
this.settings = settings;
|
||||
|
@ -122,7 +126,7 @@ namespace SafeExamBrowser.Browser
|
|||
|
||||
private void Instance_ConfigurationDetected(string url, CancelEventArgs args)
|
||||
{
|
||||
var result = uiFactory.Show(TextKey.MessageBox_ReconfigurationQuestion, TextKey.MessageBox_ReconfigurationQuestionTitle, MessageBoxAction.YesNo, MessageBoxIcon.Question);
|
||||
var result = messageBox.Show(TextKey.MessageBox_ReconfigurationQuestion, TextKey.MessageBox_ReconfigurationQuestionTitle, MessageBoxAction.YesNo, MessageBoxIcon.Question);
|
||||
var reconfigure = result == MessageBoxResult.Yes;
|
||||
var allowed = false;
|
||||
|
||||
|
@ -137,13 +141,13 @@ namespace SafeExamBrowser.Browser
|
|||
|
||||
if (!allowed)
|
||||
{
|
||||
uiFactory.Show(TextKey.MessageBox_ReconfigurationDenied, TextKey.MessageBox_ReconfigurationDeniedTitle);
|
||||
messageBox.Show(TextKey.MessageBox_ReconfigurationDenied, TextKey.MessageBox_ReconfigurationDeniedTitle);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Failed to communicate the reconfiguration request to the runtime!", e);
|
||||
uiFactory.Show(TextKey.MessageBox_ReconfigurationError, TextKey.MessageBox_ReconfigurationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_ReconfigurationError, TextKey.MessageBox_ReconfigurationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ using SafeExamBrowser.Contracts.Configuration;
|
|||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Browser
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ using System;
|
|||
using CefSharp.WinForms;
|
||||
using SafeExamBrowser.Browser.Handlers;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||
using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.BrowserSettings;
|
||||
|
||||
namespace SafeExamBrowser.Browser
|
||||
|
|
|
@ -10,8 +10,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||
using Moq;
|
||||
using SafeExamBrowser.Client.Notifications;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Client.UnitTests.Notifications
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ using Moq;
|
|||
using SafeExamBrowser.Client.Notifications;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Client.UnitTests.Notifications
|
||||
{
|
||||
|
|
|
@ -16,7 +16,9 @@ using SafeExamBrowser.Contracts.I18n;
|
|||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.Monitoring;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Client.Behaviour
|
||||
{
|
||||
|
@ -24,6 +26,7 @@ namespace SafeExamBrowser.Client.Behaviour
|
|||
{
|
||||
private IDisplayMonitor displayMonitor;
|
||||
private ILogger logger;
|
||||
private IMessageBox messageBox;
|
||||
private IOperationSequence operations;
|
||||
private IProcessMonitor processMonitor;
|
||||
private IRuntimeProxy runtime;
|
||||
|
@ -54,6 +57,7 @@ namespace SafeExamBrowser.Client.Behaviour
|
|||
public ClientController(
|
||||
IDisplayMonitor displayMonitor,
|
||||
ILogger logger,
|
||||
IMessageBox messageBox,
|
||||
IOperationSequence operations,
|
||||
IProcessMonitor processMonitor,
|
||||
IRuntimeProxy runtime,
|
||||
|
@ -64,6 +68,7 @@ namespace SafeExamBrowser.Client.Behaviour
|
|||
{
|
||||
this.displayMonitor = displayMonitor;
|
||||
this.logger = logger;
|
||||
this.messageBox = messageBox;
|
||||
this.operations = operations;
|
||||
this.processMonitor = processMonitor;
|
||||
this.runtime = runtime;
|
||||
|
@ -186,7 +191,7 @@ namespace SafeExamBrowser.Client.Behaviour
|
|||
private void Runtime_ConnectionLost()
|
||||
{
|
||||
logger.Error("Lost connection to the runtime!");
|
||||
uiFactory.Show(TextKey.MessageBox_ApplicationError, TextKey.MessageBox_ApplicationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_ApplicationError, TextKey.MessageBox_ApplicationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
|
||||
taskbar.Close();
|
||||
shutdown.Invoke();
|
||||
|
@ -194,7 +199,7 @@ namespace SafeExamBrowser.Client.Behaviour
|
|||
|
||||
private void Taskbar_QuitButtonClicked()
|
||||
{
|
||||
var result = uiFactory.Show(TextKey.MessageBox_Quit, TextKey.MessageBox_QuitTitle, MessageBoxAction.YesNo, MessageBoxIcon.Question);
|
||||
var result = messageBox.Show(TextKey.MessageBox_Quit, TextKey.MessageBox_QuitTitle, MessageBoxAction.YesNo, MessageBoxIcon.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
|
@ -205,7 +210,7 @@ namespace SafeExamBrowser.Client.Behaviour
|
|||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Failed to communicate shutdown request to the runtime!", e);
|
||||
uiFactory.Show(TextKey.MessageBox_QuitError, TextKey.MessageBox_QuitErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_QuitError, TextKey.MessageBox_QuitErrorTitle, icon: MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ using SafeExamBrowser.Contracts.Configuration;
|
|||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
using SafeExamBrowser.Contracts.WindowsApi;
|
||||
using SafeExamBrowser.Core.Behaviour.OperationModel;
|
||||
using SafeExamBrowser.Core.Communication;
|
||||
|
@ -47,6 +48,7 @@ namespace SafeExamBrowser.Client
|
|||
private ClientConfiguration configuration;
|
||||
private IClientHost clientHost;
|
||||
private ILogger logger;
|
||||
private IMessageBox messageBox;
|
||||
private INativeMethods nativeMethods;
|
||||
private IRuntimeProxy runtimeProxy;
|
||||
private ISystemInfo systemInfo;
|
||||
|
@ -68,6 +70,7 @@ namespace SafeExamBrowser.Client
|
|||
InitializeLogging();
|
||||
|
||||
text = new Text(logger);
|
||||
messageBox = new MessageBox(text);
|
||||
uiFactory = new UserInterfaceFactory(text);
|
||||
runtimeProxy = new RuntimeProxy(runtimeHostUri, new ModuleLogger(logger, typeof(RuntimeProxy)));
|
||||
|
||||
|
@ -96,7 +99,7 @@ namespace SafeExamBrowser.Client
|
|||
|
||||
var sequence = new OperationSequence(logger, operations);
|
||||
|
||||
ClientController = new ClientController(displayMonitor, logger, sequence, processMonitor, runtimeProxy, shutdown, Taskbar, uiFactory, windowMonitor);
|
||||
ClientController = new ClientController(displayMonitor, logger, messageBox, sequence, processMonitor, runtimeProxy, shutdown, Taskbar, uiFactory, windowMonitor);
|
||||
}
|
||||
|
||||
internal void LogStartupInformation()
|
||||
|
@ -145,7 +148,7 @@ namespace SafeExamBrowser.Client
|
|||
private IOperation BuildBrowserOperation()
|
||||
{
|
||||
var moduleLogger = new ModuleLogger(logger, typeof(BrowserApplicationController));
|
||||
var browserController = new BrowserApplicationController(configuration.Settings.Browser, configuration.RuntimeInfo, moduleLogger, runtimeProxy, text, uiFactory);
|
||||
var browserController = new BrowserApplicationController(configuration.Settings.Browser, configuration.RuntimeInfo, moduleLogger, messageBox, runtimeProxy, text, uiFactory);
|
||||
var browserInfo = new BrowserApplicationInfo();
|
||||
var operation = new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory);
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
using SafeExamBrowser.Contracts.Behaviour;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Client.Notifications
|
||||
{
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
*/
|
||||
|
||||
using SafeExamBrowser.Contracts.Behaviour;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Client.Notifications
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
using System;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Contracts.Configuration
|
||||
{
|
||||
|
|
|
@ -123,14 +123,14 @@
|
|||
<Compile Include="SystemComponents\ISystemComponent.cs" />
|
||||
<Compile Include="SystemComponents\IWirelessNetwork.cs" />
|
||||
<Compile Include="SystemComponents\WirelessNetworkStatus.cs" />
|
||||
<Compile Include="UserInterface\IBrowserControl.cs" />
|
||||
<Compile Include="UserInterface\IBrowserWindow.cs" />
|
||||
<Compile Include="UserInterface\IMessageBox.cs" />
|
||||
<Compile Include="UserInterface\Browser\IBrowserControl.cs" />
|
||||
<Compile Include="UserInterface\Browser\IBrowserWindow.cs" />
|
||||
<Compile Include="UserInterface\MessageBox\IMessageBox.cs" />
|
||||
<Compile Include="UserInterface\IProgressIndicator.cs" />
|
||||
<Compile Include="UserInterface\IRuntimeWindow.cs" />
|
||||
<Compile Include="UserInterface\MessageBoxResult.cs" />
|
||||
<Compile Include="UserInterface\Windows\IRuntimeWindow.cs" />
|
||||
<Compile Include="UserInterface\MessageBox\MessageBoxResult.cs" />
|
||||
<Compile Include="UserInterface\Taskbar\INotificationButton.cs" />
|
||||
<Compile Include="UserInterface\ISplashScreen.cs" />
|
||||
<Compile Include="UserInterface\Windows\ISplashScreen.cs" />
|
||||
<Compile Include="UserInterface\Taskbar\ISystemKeyboardLayoutControl.cs" />
|
||||
<Compile Include="UserInterface\Taskbar\ISystemPowerSupplyControl.cs" />
|
||||
<Compile Include="UserInterface\Taskbar\ISystemControl.cs" />
|
||||
|
@ -140,9 +140,9 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UserInterface\Taskbar\IApplicationButton.cs" />
|
||||
<Compile Include="UserInterface\IUserInterfaceFactory.cs" />
|
||||
<Compile Include="UserInterface\IWindow.cs" />
|
||||
<Compile Include="UserInterface\MessageBoxAction.cs" />
|
||||
<Compile Include="UserInterface\MessageBoxIcon.cs" />
|
||||
<Compile Include="UserInterface\Windows\IWindow.cs" />
|
||||
<Compile Include="UserInterface\MessageBox\MessageBoxAction.cs" />
|
||||
<Compile Include="UserInterface\MessageBox\MessageBoxIcon.cs" />
|
||||
<Compile Include="WindowsApi\IBounds.cs" />
|
||||
<Compile Include="WindowsApi\IDesktop.cs" />
|
||||
<Compile Include="WindowsApi\INativeMethods.cs" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.Browser
|
||||
{
|
||||
public delegate void AddressChangedEventHandler(string address);
|
||||
public delegate void LoadingStateChangedEventHandler(bool isLoading);
|
|
@ -6,7 +6,9 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.Browser
|
||||
{
|
||||
public delegate void ActionRequestedEventHandler();
|
||||
|
|
@ -9,7 +9,9 @@
|
|||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
{
|
||||
|
@ -18,7 +20,7 @@ namespace SafeExamBrowser.Contracts.UserInterface
|
|||
/// from the particular user interface framework in use, all dynamically generated user interface elements must be generated by this
|
||||
/// factory.
|
||||
/// </summary>
|
||||
public interface IUserInterfaceFactory : IMessageBox
|
||||
public interface IUserInterfaceFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new about window displaying information about the currently running application version.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.MessageBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the API for message boxes.
|
|
@ -6,7 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.MessageBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines all actions available for a message box.
|
|
@ -6,7 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.MessageBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines all icons available in a message box.
|
|
@ -6,7 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.MessageBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines all possible results of a message box.
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// The main window of the runtime application component. It is controlled by the <see cref="Behaviour.IRuntimeController"/> and serves
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the functionality of a splash screen.
|
|
@ -6,7 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Contracts.UserInterface
|
||||
namespace SafeExamBrowser.Contracts.UserInterface.Windows
|
||||
{
|
||||
public delegate void WindowClosingEventHandler();
|
||||
|
|
@ -16,6 +16,7 @@ using SafeExamBrowser.Contracts.Configuration.Settings;
|
|||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
using SafeExamBrowser.Runtime.Behaviour.Operations;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
||||
|
@ -24,22 +25,22 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public class ConfigurationOperationTests
|
||||
{
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private RuntimeInfo info;
|
||||
private Mock<IConfigurationRepository> repository;
|
||||
private Settings settings;
|
||||
private Mock<IText> text;
|
||||
private Mock<IUserInterfaceFactory> uiFactory;
|
||||
private ConfigurationOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
logger = new Mock<ILogger>();
|
||||
info = new RuntimeInfo();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
repository = new Mock<IConfigurationRepository>();
|
||||
settings = new Settings();
|
||||
text = new Mock<IText>();
|
||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||
|
||||
info.AppDataFolder = @"C:\Not\Really\AppData";
|
||||
info.DefaultSettingsFileName = "SettingsDummy.txt";
|
||||
|
@ -53,11 +54,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
repository.Setup(r => r.LoadDefaultSettings());
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, new string[] { });
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, new string[] { });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -69,7 +70,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
var path = @"an/invalid\path.'*%yolo/()";
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, new [] { "blubb.exe", path });
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, new [] { "blubb.exe", path });
|
||||
|
||||
sut.Perform();
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
info.ProgramDataFolder = location;
|
||||
info.AppDataFolder = location;
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, new[] { "blubb.exe", path });
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, new[] { "blubb.exe", path });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -98,7 +99,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
info.ProgramDataFolder = location;
|
||||
info.AppDataFolder = $@"{location}\WRONG";
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -112,7 +113,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
|
||||
info.AppDataFolder = location;
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -122,7 +123,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
[TestMethod]
|
||||
public void MustFallbackToDefaultsAsLastPrio()
|
||||
{
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -133,9 +134,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustAbortIfWishedByUser()
|
||||
{
|
||||
info.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
uiFactory.Setup(u => u.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.Yes);
|
||||
messageBox.Setup(u => u.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.Yes);
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, null);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
|
@ -145,9 +146,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
[TestMethod]
|
||||
public void MustNotAbortIfNotWishedByUser()
|
||||
{
|
||||
uiFactory.Setup(u => u.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.No);
|
||||
messageBox.Setup(u => u.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.No);
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, info, text.Object, null);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ using SafeExamBrowser.Contracts.Configuration.Settings;
|
|||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.Behaviour.Operations
|
||||
{
|
||||
|
@ -21,9 +22,9 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
|
|||
{
|
||||
private IConfigurationRepository repository;
|
||||
private ILogger logger;
|
||||
private IMessageBox messageBox;
|
||||
private RuntimeInfo runtimeInfo;
|
||||
private IText text;
|
||||
private IUserInterfaceFactory uiFactory;
|
||||
private string[] commandLineArgs;
|
||||
|
||||
public IProgressIndicator ProgressIndicator { private get; set; }
|
||||
|
@ -31,17 +32,17 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
|
|||
public ConfigurationOperation(
|
||||
IConfigurationRepository repository,
|
||||
ILogger logger,
|
||||
IMessageBox messageBox,
|
||||
RuntimeInfo runtimeInfo,
|
||||
IText text,
|
||||
IUserInterfaceFactory uiFactory,
|
||||
string[] commandLineArgs)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.logger = logger;
|
||||
this.messageBox = messageBox;
|
||||
this.commandLineArgs = commandLineArgs;
|
||||
this.runtimeInfo = runtimeInfo;
|
||||
this.text = text;
|
||||
this.uiFactory = uiFactory;
|
||||
}
|
||||
|
||||
public OperationResult Perform()
|
||||
|
@ -129,7 +130,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
|
|||
{
|
||||
var message = text.Get(TextKey.MessageBox_ClientConfigurationQuestion);
|
||||
var title = text.Get(TextKey.MessageBox_ClientConfigurationQuestionTitle);
|
||||
var abort = uiFactory.Show(message, title, MessageBoxAction.YesNo, MessageBoxIcon.Question);
|
||||
var abort = messageBox.Show(message, title, MessageBoxAction.YesNo, MessageBoxIcon.Question);
|
||||
|
||||
return abort == MessageBoxResult.Yes;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ using SafeExamBrowser.Contracts.Configuration.Settings;
|
|||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.Behaviour
|
||||
{
|
||||
|
@ -24,6 +26,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
|
||||
private IConfigurationRepository configuration;
|
||||
private ILogger logger;
|
||||
private IMessageBox messageBox;
|
||||
private IOperationSequence bootstrapSequence;
|
||||
private IOperationSequence sessionSequence;
|
||||
private IRuntimeHost runtimeHost;
|
||||
|
@ -37,6 +40,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
public RuntimeController(
|
||||
IConfigurationRepository configuration,
|
||||
ILogger logger,
|
||||
IMessageBox messageBox,
|
||||
IOperationSequence bootstrapSequence,
|
||||
IOperationSequence sessionSequence,
|
||||
IRuntimeHost runtimeHost,
|
||||
|
@ -46,11 +50,12 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
IUserInterfaceFactory uiFactory)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.logger = logger;
|
||||
this.bootstrapSequence = bootstrapSequence;
|
||||
this.sessionSequence = sessionSequence;
|
||||
this.logger = logger;
|
||||
this.messageBox = messageBox;
|
||||
this.runtimeHost = runtimeHost;
|
||||
this.runtimeInfo = runtimeInfo;
|
||||
this.sessionSequence = sessionSequence;
|
||||
this.service = service;
|
||||
this.shutdown = shutdown;
|
||||
this.uiFactory = uiFactory;
|
||||
|
@ -86,7 +91,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
logger.Info("--- Application startup aborted! ---");
|
||||
logger.Log(string.Empty);
|
||||
|
||||
uiFactory.Show(TextKey.MessageBox_StartupError, TextKey.MessageBox_StartupErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_StartupError, TextKey.MessageBox_StartupErrorTitle, icon: MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
return initialized && sessionRunning;
|
||||
|
@ -121,7 +126,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
logger.Info("--- Shutdown procedure failed! ---");
|
||||
logger.Log(string.Empty);
|
||||
|
||||
uiFactory.Show(TextKey.MessageBox_ShutdownError, TextKey.MessageBox_ShutdownErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_ShutdownError, TextKey.MessageBox_ShutdownErrorTitle, icon: MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
splashScreen?.Close();
|
||||
|
@ -163,7 +168,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
|
||||
if (result == OperationResult.Failed)
|
||||
{
|
||||
uiFactory.Show(TextKey.MessageBox_SessionStartError, TextKey.MessageBox_SessionStartErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_SessionStartError, TextKey.MessageBox_SessionStartErrorTitle, icon: MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
if (!initial)
|
||||
|
@ -193,7 +198,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
else
|
||||
{
|
||||
logger.Info(">>>--- Session reversion was erroneous! ---<<<");
|
||||
uiFactory.Show(TextKey.MessageBox_SessionStopError, TextKey.MessageBox_SessionStopErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_SessionStopError, TextKey.MessageBox_SessionStopErrorTitle, icon: MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +230,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
{
|
||||
logger.Error($"Client application has unexpectedly terminated with exit code {exitCode}!");
|
||||
// TODO: Check if message box is rendered on new desktop as well -> otherwise shutdown is blocked!
|
||||
uiFactory.Show(TextKey.MessageBox_ApplicationError, TextKey.MessageBox_ApplicationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_ApplicationError, TextKey.MessageBox_ApplicationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
|
||||
shutdown.Invoke();
|
||||
}
|
||||
|
@ -234,7 +239,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
|
|||
{
|
||||
logger.Error("Lost connection to the client application!");
|
||||
// TODO: Check if message box is rendered on new desktop as well -> otherwise shutdown is blocked!
|
||||
uiFactory.Show(TextKey.MessageBox_ApplicationError, TextKey.MessageBox_ApplicationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
messageBox.Show(TextKey.MessageBox_ApplicationError, TextKey.MessageBox_ApplicationErrorTitle, icon: MessageBoxIcon.Error);
|
||||
|
||||
shutdown.Invoke();
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace SafeExamBrowser.Runtime
|
|||
InitializeLogging();
|
||||
|
||||
var text = new Text(logger);
|
||||
var messageBox = new MessageBox(text);
|
||||
var uiFactory = new UserInterfaceFactory(text);
|
||||
var desktop = new Desktop(new ModuleLogger(logger, typeof(Desktop)));
|
||||
var processFactory = new ProcessFactory(desktop, new ModuleLogger(logger, typeof(ProcessFactory)));
|
||||
|
@ -61,7 +62,7 @@ namespace SafeExamBrowser.Runtime
|
|||
bootstrapOperations.Enqueue(new CommunicationOperation(runtimeHost, logger));
|
||||
|
||||
sessionOperations.Enqueue(new SessionSequenceStartOperation(sessionController));
|
||||
sessionOperations.Enqueue(new ConfigurationOperation(configuration, logger, runtimeInfo, text, uiFactory, args));
|
||||
sessionOperations.Enqueue(new ConfigurationOperation(configuration, logger, messageBox, runtimeInfo, text, args));
|
||||
sessionOperations.Enqueue(new ServiceConnectionOperation(configuration, logger, serviceProxy, text));
|
||||
sessionOperations.Enqueue(new KioskModeOperation(logger, configuration));
|
||||
sessionOperations.Enqueue(new SessionSequenceEndOperation(sessionController));
|
||||
|
@ -69,7 +70,7 @@ namespace SafeExamBrowser.Runtime
|
|||
var boostrapSequence = new OperationSequence(logger, bootstrapOperations);
|
||||
var sessionSequence = new OperationSequence(logger, sessionOperations);
|
||||
|
||||
RuntimeController = new RuntimeController(configuration, logger, boostrapSequence, sessionSequence, runtimeHost, runtimeInfo, serviceProxy, shutdown, uiFactory);
|
||||
RuntimeController = new RuntimeController(configuration, logger, messageBox, boostrapSequence, sessionSequence, runtimeHost, runtimeInfo, serviceProxy, shutdown, uiFactory);
|
||||
}
|
||||
|
||||
internal void LogStartupInformation()
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows;
|
|||
using System.Windows.Documents;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
{
|
||||
|
|
|
@ -10,7 +10,8 @@ using System;
|
|||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Classic.Utilities;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.ComponentModel;
|
|||
using System.Windows;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Classic.ViewModels;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
|
|
82
SafeExamBrowser.UserInterface.Classic/MessageBox.cs
Normal file
82
SafeExamBrowser.UserInterface.Classic/MessageBox.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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.Windows;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
|
||||
using MessageBoxResult = SafeExamBrowser.Contracts.UserInterface.MessageBox.MessageBoxResult;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
{
|
||||
public class MessageBox : IMessageBox
|
||||
{
|
||||
private IText text;
|
||||
|
||||
public MessageBox(IText text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
|
||||
{
|
||||
// The last two parameters are an unfortunate necessity, since e.g. splash screens are displayed topmost while running in their
|
||||
// own thread / dispatcher, and would thus conceal the message box...
|
||||
var result = System.Windows.MessageBox.Show(message, title, ToButton(action), ToImage(icon), System.Windows.MessageBoxResult.None, MessageBoxOptions.ServiceNotification);
|
||||
|
||||
return ToResult(result);
|
||||
}
|
||||
|
||||
public MessageBoxResult Show(TextKey message, TextKey title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
|
||||
{
|
||||
return Show(text.Get(message), text.Get(title), action, icon);
|
||||
}
|
||||
|
||||
private MessageBoxButton ToButton(MessageBoxAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MessageBoxAction.YesNo:
|
||||
return MessageBoxButton.YesNo;
|
||||
default:
|
||||
return MessageBoxButton.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private MessageBoxImage ToImage(MessageBoxIcon icon)
|
||||
{
|
||||
switch (icon)
|
||||
{
|
||||
case MessageBoxIcon.Error:
|
||||
return MessageBoxImage.Error;
|
||||
case MessageBoxIcon.Question:
|
||||
return MessageBoxImage.Question;
|
||||
case MessageBoxIcon.Warning:
|
||||
return MessageBoxImage.Warning;
|
||||
default:
|
||||
return MessageBoxImage.Information;
|
||||
}
|
||||
}
|
||||
|
||||
private MessageBoxResult ToResult(System.Windows.MessageBoxResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case System.Windows.MessageBoxResult.Cancel:
|
||||
return MessageBoxResult.Cancel;
|
||||
case System.Windows.MessageBoxResult.No:
|
||||
return MessageBoxResult.No;
|
||||
case System.Windows.MessageBoxResult.OK:
|
||||
return MessageBoxResult.Ok;
|
||||
case System.Windows.MessageBoxResult.Yes:
|
||||
return MessageBoxResult.Yes;
|
||||
default:
|
||||
return MessageBoxResult.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ using System.Windows.Documents;
|
|||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Classic.ViewModels;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
<Compile Include="LogWindow.xaml.cs">
|
||||
<DependentUpon>LogWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MessageBox.cs" />
|
||||
<Compile Include="RuntimeWindow.xaml.cs">
|
||||
<DependentUpon>RuntimeWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows;
|
|||
using System.Windows.Documents;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Classic.ViewModels;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
*/
|
||||
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Classic.Controls;
|
||||
using SafeExamBrowser.UserInterface.Classic.Utilities;
|
||||
using MessageBoxResult = SafeExamBrowser.Contracts.UserInterface.MessageBoxResult;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Classic
|
||||
{
|
||||
|
@ -137,62 +137,5 @@ namespace SafeExamBrowser.UserInterface.Classic
|
|||
{
|
||||
return new WirelessNetworkControl();
|
||||
}
|
||||
|
||||
public MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
|
||||
{
|
||||
// The last two parameters are an unfortunate necessity, since e.g. splash screens are displayed topmost while running in their
|
||||
// own thread / dispatcher, and would thus conceal the message box...
|
||||
var result = MessageBox.Show(message, title, ToButton(action), ToImage(icon), System.Windows.MessageBoxResult.None, MessageBoxOptions.ServiceNotification);
|
||||
|
||||
return ToResult(result);
|
||||
}
|
||||
|
||||
public MessageBoxResult Show(TextKey message, TextKey title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
|
||||
{
|
||||
return Show(text.Get(message), text.Get(title), action, icon);
|
||||
}
|
||||
|
||||
private MessageBoxButton ToButton(MessageBoxAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MessageBoxAction.YesNo:
|
||||
return MessageBoxButton.YesNo;
|
||||
default:
|
||||
return MessageBoxButton.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private MessageBoxImage ToImage(MessageBoxIcon icon)
|
||||
{
|
||||
switch (icon)
|
||||
{
|
||||
case MessageBoxIcon.Error:
|
||||
return MessageBoxImage.Error;
|
||||
case MessageBoxIcon.Question:
|
||||
return MessageBoxImage.Question;
|
||||
case MessageBoxIcon.Warning:
|
||||
return MessageBoxImage.Warning;
|
||||
default:
|
||||
return MessageBoxImage.Information;
|
||||
}
|
||||
}
|
||||
|
||||
private MessageBoxResult ToResult(System.Windows.MessageBoxResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case System.Windows.MessageBoxResult.Cancel:
|
||||
return MessageBoxResult.Cancel;
|
||||
case System.Windows.MessageBoxResult.No:
|
||||
return MessageBoxResult.No;
|
||||
case System.Windows.MessageBoxResult.OK:
|
||||
return MessageBoxResult.Ok;
|
||||
case System.Windows.MessageBoxResult.Yes:
|
||||
return MessageBoxResult.Yes;
|
||||
default:
|
||||
return MessageBoxResult.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows;
|
|||
using System.Windows.Documents;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Windows10
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.ComponentModel;
|
|||
using System.Windows;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Windows10.ViewModels;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Windows10
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows;
|
|||
using System.Windows.Documents;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Windows10.ViewModels;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Windows10
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
*/
|
||||
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using SafeExamBrowser.Contracts.Configuration;
|
||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||
using SafeExamBrowser.Contracts.I18n;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.UserInterface;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
||||
using SafeExamBrowser.UserInterface.Windows10.Controls;
|
||||
using MessageBoxResult = SafeExamBrowser.Contracts.UserInterface.MessageBoxResult;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Windows10
|
||||
{
|
||||
|
@ -122,62 +122,5 @@ namespace SafeExamBrowser.UserInterface.Windows10
|
|||
// TODO
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
|
||||
{
|
||||
// The last two parameters are an unfortunate necessity, since e.g. splash screens are displayed topmost while running in their
|
||||
// own thread / dispatcher, and would thus conceal the message box...
|
||||
var result = MessageBox.Show(message, title, ToButton(action), ToImage(icon), System.Windows.MessageBoxResult.None, MessageBoxOptions.ServiceNotification);
|
||||
|
||||
return ToResult(result);
|
||||
}
|
||||
|
||||
public MessageBoxResult Show(TextKey message, TextKey title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
|
||||
{
|
||||
return Show(text.Get(message), text.Get(title), action, icon);
|
||||
}
|
||||
|
||||
private MessageBoxButton ToButton(MessageBoxAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MessageBoxAction.YesNo:
|
||||
return MessageBoxButton.YesNo;
|
||||
default:
|
||||
return MessageBoxButton.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private MessageBoxImage ToImage(MessageBoxIcon icon)
|
||||
{
|
||||
switch (icon)
|
||||
{
|
||||
case MessageBoxIcon.Error:
|
||||
return MessageBoxImage.Error;
|
||||
case MessageBoxIcon.Question:
|
||||
return MessageBoxImage.Question;
|
||||
case MessageBoxIcon.Warning:
|
||||
return MessageBoxImage.Warning;
|
||||
default:
|
||||
return MessageBoxImage.Information;
|
||||
}
|
||||
}
|
||||
|
||||
private MessageBoxResult ToResult(System.Windows.MessageBoxResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case System.Windows.MessageBoxResult.Cancel:
|
||||
return MessageBoxResult.Cancel;
|
||||
case System.Windows.MessageBoxResult.No:
|
||||
return MessageBoxResult.No;
|
||||
case System.Windows.MessageBoxResult.OK:
|
||||
return MessageBoxResult.Ok;
|
||||
case System.Windows.MessageBoxResult.Yes:
|
||||
return MessageBoxResult.Yes;
|
||||
default:
|
||||
return MessageBoxResult.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue