SEBWIN-219: Extracted text dependency from user interface factory methods.

This commit is contained in:
dbuechel 2018-02-07 13:25:49 +01:00
parent 8cd0659a22
commit 001c262158
16 changed files with 110 additions and 85 deletions

View file

@ -19,14 +19,12 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
public class AboutNotificationControllerTests public class AboutNotificationControllerTests
{ {
private Mock<IRuntimeInfo> runtimeInfoMock; private Mock<IRuntimeInfo> runtimeInfoMock;
private Mock<IText> textMock;
private Mock<IUserInterfaceFactory> uiFactoryMock; private Mock<IUserInterfaceFactory> uiFactoryMock;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
runtimeInfoMock = new Mock<IRuntimeInfo>(); runtimeInfoMock = new Mock<IRuntimeInfo>();
textMock = new Mock<IText>();
uiFactoryMock = new Mock<IUserInterfaceFactory>(); uiFactoryMock = new Mock<IUserInterfaceFactory>();
} }
@ -35,9 +33,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var window = new Mock<IWindow>(); var window = new Mock<IWindow>();
var sut = new AboutNotificationController(runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object);
uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<IRuntimeInfo>(), It.IsAny<IText>())).Returns(window.Object); uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<IRuntimeInfo>())).Returns(window.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);
button.Click(); button.Click();
sut.Terminate(); sut.Terminate();
@ -50,9 +48,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var window = new Mock<IWindow>(); var window = new Mock<IWindow>();
var sut = new AboutNotificationController(runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object);
uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<IRuntimeInfo>(), It.IsAny<IText>())).Returns(window.Object); uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<IRuntimeInfo>())).Returns(window.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);
button.Click(); button.Click();
button.Click(); button.Click();
@ -60,7 +58,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
button.Click(); button.Click();
button.Click(); button.Click();
uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny<IRuntimeInfo>(), It.IsAny<IText>()), Times.Once); uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny<IRuntimeInfo>()), Times.Once);
window.Verify(u => u.Show(), Times.Once); window.Verify(u => u.Show(), Times.Once);
window.Verify(u => u.BringToForeground(), Times.Exactly(4)); window.Verify(u => u.BringToForeground(), Times.Exactly(4));
} }
@ -69,7 +67,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
public void MustSubscribeToClickEvent() public void MustSubscribeToClickEvent()
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var sut = new AboutNotificationController(runtimeInfoMock.Object, textMock.Object, uiFactoryMock.Object); var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);

View file

@ -9,7 +9,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq; using Moq;
using SafeExamBrowser.Client.Notifications; using SafeExamBrowser.Client.Notifications;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.Contracts.UserInterface;
@ -19,14 +18,12 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
public class LogNotificationControllerTests public class LogNotificationControllerTests
{ {
private Mock<ILogger> loggerMock; private Mock<ILogger> loggerMock;
private Mock<IText> textMock;
private Mock<IUserInterfaceFactory> uiFactoryMock; private Mock<IUserInterfaceFactory> uiFactoryMock;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
loggerMock = new Mock<ILogger>(); loggerMock = new Mock<ILogger>();
textMock = new Mock<IText>();
uiFactoryMock = new Mock<IUserInterfaceFactory>(); uiFactoryMock = new Mock<IUserInterfaceFactory>();
} }
@ -35,9 +32,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var window = new Mock<IWindow>(); var window = new Mock<IWindow>();
var sut = new LogNotificationController(loggerMock.Object, textMock.Object, uiFactoryMock.Object); var sut = new LogNotificationController(loggerMock.Object, uiFactoryMock.Object);
uiFactoryMock.Setup(u => u.CreateLogWindow(It.IsAny<ILogger>(), It.IsAny<IText>())).Returns(window.Object); uiFactoryMock.Setup(u => u.CreateLogWindow(It.IsAny<ILogger>())).Returns(window.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);
button.Click(); button.Click();
sut.Terminate(); sut.Terminate();
@ -50,9 +47,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var window = new Mock<IWindow>(); var window = new Mock<IWindow>();
var sut = new LogNotificationController(loggerMock.Object, textMock.Object, uiFactoryMock.Object); var sut = new LogNotificationController(loggerMock.Object, uiFactoryMock.Object);
uiFactoryMock.Setup(u => u.CreateLogWindow(It.IsAny<ILogger>(), It.IsAny<IText>())).Returns(window.Object); uiFactoryMock.Setup(u => u.CreateLogWindow(It.IsAny<ILogger>())).Returns(window.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);
button.Click(); button.Click();
button.Click(); button.Click();
@ -60,7 +57,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
button.Click(); button.Click();
button.Click(); button.Click();
uiFactoryMock.Verify(u => u.CreateLogWindow(It.IsAny<ILogger>(), It.IsAny<IText>()), Times.Once); uiFactoryMock.Verify(u => u.CreateLogWindow(It.IsAny<ILogger>()), Times.Once);
window.Verify(u => u.Show(), Times.Once); window.Verify(u => u.Show(), Times.Once);
window.Verify(u => u.BringToForeground(), Times.Exactly(4)); window.Verify(u => u.BringToForeground(), Times.Exactly(4));
} }
@ -69,7 +66,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
public void MustSubscribeToClickEvent() public void MustSubscribeToClickEvent()
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var sut = new LogNotificationController(loggerMock.Object, textMock.Object, uiFactoryMock.Object); var sut = new LogNotificationController(loggerMock.Object, uiFactoryMock.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);

View file

@ -140,10 +140,11 @@ namespace SafeExamBrowser.Client.Behaviour.Operations
private void CreateLogNotification() private void CreateLogNotification()
{ {
// TODO: Resolve dependencies -> CompositionRoot!
var logInfo = new LogNotificationInfo(text); var logInfo = new LogNotificationInfo(text);
var logNotification = uiFactory.CreateNotification(logInfo); var logNotification = uiFactory.CreateNotification(logInfo);
logController = new LogNotificationController(logger, text, uiFactory); logController = new LogNotificationController(logger, uiFactory);
logController.RegisterNotification(logNotification); logController.RegisterNotification(logNotification);
taskbar.AddNotification(logNotification); taskbar.AddNotification(logNotification);

View file

@ -9,7 +9,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using SafeExamBrowser.Browser; using SafeExamBrowser.Browser;
using SafeExamBrowser.Configuration; using SafeExamBrowser.Configuration;
using SafeExamBrowser.Configuration.Settings;
using SafeExamBrowser.Contracts.Behaviour; using SafeExamBrowser.Contracts.Behaviour;
using SafeExamBrowser.Contracts.Behaviour.Operations; using SafeExamBrowser.Contracts.Behaviour.Operations;
using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration;
@ -60,11 +59,11 @@ namespace SafeExamBrowser.Client
nativeMethods = new NativeMethods(); nativeMethods = new NativeMethods();
settings = new ConfigurationRepository().LoadDefaultSettings(); settings = new ConfigurationRepository().LoadDefaultSettings();
systemInfo = new SystemInfo(); systemInfo = new SystemInfo();
uiFactory = new UserInterfaceFactory();
InitializeLogging(); InitializeLogging();
text = new Text(logger); text = new Text(logger);
uiFactory = new UserInterfaceFactory(text);
// TODO // TODO
//Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar))); //Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar)));
//browserController = new BrowserApplicationController(settings.Browser, text, uiFactory); //browserController = new BrowserApplicationController(settings.Browser, text, uiFactory);

View file

@ -18,14 +18,12 @@ namespace SafeExamBrowser.Client.Notifications
{ {
private INotificationButton notification; private INotificationButton notification;
private IRuntimeInfo runtimeInfo; private IRuntimeInfo runtimeInfo;
private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
private IWindow window; private IWindow window;
public AboutNotificationController(IRuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory) public AboutNotificationController(IRuntimeInfo runtimeInfo, IUserInterfaceFactory uiFactory)
{ {
this.runtimeInfo = runtimeInfo; this.runtimeInfo = runtimeInfo;
this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
} }
@ -45,7 +43,7 @@ namespace SafeExamBrowser.Client.Notifications
{ {
if (window == null) if (window == null)
{ {
window = uiFactory.CreateAboutWindow(runtimeInfo, text); window = uiFactory.CreateAboutWindow(runtimeInfo);
window.Closing += () => window = null; window.Closing += () => window = null;
window.Show(); window.Show();

View file

@ -18,14 +18,12 @@ namespace SafeExamBrowser.Client.Notifications
{ {
private INotificationButton notification; private INotificationButton notification;
private ILogger logger; private ILogger logger;
private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
private IWindow window; private IWindow window;
public LogNotificationController(ILogger logger, IText text, IUserInterfaceFactory uiFactory) public LogNotificationController(ILogger logger, IUserInterfaceFactory uiFactory)
{ {
this.logger = logger; this.logger = logger;
this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
} }
@ -45,7 +43,7 @@ namespace SafeExamBrowser.Client.Notifications
{ {
if (window == null) if (window == null)
{ {
window = uiFactory.CreateLogWindow(logger, text); window = uiFactory.CreateLogWindow(logger);
window.Closing += () => window = null; window.Closing += () => window = null;
window.Show(); window.Show();

View file

@ -13,14 +13,13 @@ namespace SafeExamBrowser.Client.Notifications
{ {
internal class LogNotificationInfo : INotificationInfo internal class LogNotificationInfo : INotificationInfo
{ {
private IText text; public string Tooltip { get; private set; }
public IIconResource IconResource { get; private set; }
public string Tooltip => text.Get(TextKey.Notification_LogTooltip);
public IIconResource IconResource { get; } = new LogNotificationIconResource();
public LogNotificationInfo(IText text) public LogNotificationInfo(IText text)
{ {
this.text = text; Tooltip = text.Get(TextKey.Notification_LogTooltip);
IconResource = new LogNotificationIconResource();
} }
} }
} }

View file

@ -17,6 +17,8 @@ namespace SafeExamBrowser.Contracts.I18n
LogWindow_Title, LogWindow_Title,
MessageBox_ConfigureClientSuccess, MessageBox_ConfigureClientSuccess,
MessageBox_ConfigureClientSuccessTitle, MessageBox_ConfigureClientSuccessTitle,
MessageBox_SessionStartError,
MessageBox_SessionStartErrorTitle,
MessageBox_ShutdownError, MessageBox_ShutdownError,
MessageBox_ShutdownErrorTitle, MessageBox_ShutdownErrorTitle,
MessageBox_SingleInstance, MessageBox_SingleInstance,

View file

@ -6,6 +6,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
using SafeExamBrowser.Contracts.I18n;
namespace SafeExamBrowser.Contracts.UserInterface namespace SafeExamBrowser.Contracts.UserInterface
{ {
public interface IMessageBox public interface IMessageBox
@ -14,5 +16,10 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// Shows a message box according to the specified parameters and returns the result chosen by the user. /// Shows a message box according to the specified parameters and returns the result chosen by the user.
/// </summary> /// </summary>
MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information); MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information);
/// <summary>
/// Shows a message box according to the specified parameters and returns the result chosen by the user.
/// </summary>
MessageBoxResult Show(TextKey message, TextKey title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information);
} }
} }

View file

@ -8,7 +8,6 @@
using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.Configuration.Settings; using SafeExamBrowser.Contracts.Configuration.Settings;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.UserInterface.Taskbar; using SafeExamBrowser.Contracts.UserInterface.Taskbar;
@ -19,7 +18,7 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// <summary> /// <summary>
/// Creates a new about window displaying information about the currently running application version. /// Creates a new about window displaying information about the currently running application version.
/// </summary> /// </summary>
IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo, IText text); IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo);
/// <summary> /// <summary>
/// Creates a taskbar button, initialized with the given application information. /// Creates a taskbar button, initialized with the given application information.
@ -34,7 +33,7 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// <summary> /// <summary>
/// Creates a new log window which runs on its own thread. /// Creates a new log window which runs on its own thread.
/// </summary> /// </summary>
IWindow CreateLogWindow(ILogger logger, IText text); IWindow CreateLogWindow(ILogger logger);
/// <summary> /// <summary>
/// Creates a taskbar notification, initialized with the given notification information. /// Creates a taskbar notification, initialized with the given notification information.
@ -55,12 +54,12 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// Creates a new runtime window which runs on its own thread. /// Creates a new runtime window which runs on its own thread.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo, IText text); IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo);
/// <summary> /// <summary>
/// Creates a new splash screen which runs on its own thread. /// Creates a new splash screen which runs on its own thread.
/// </summary> /// </summary>
ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo, IText text); ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo);
/// <summary> /// <summary>
/// Creates a system control which allows to change the wireless network connection of the computer. /// Creates a system control which allows to change the wireless network connection of the computer.

View file

@ -531,7 +531,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour.Operations
var sut = new OperationSequence(loggerMock.Object, new Queue<IOperation>()); var sut = new OperationSequence(loggerMock.Object, new Queue<IOperation>());
var indicatorMock = new Mock<IProgressIndicator>(); var indicatorMock = new Mock<IProgressIndicator>();
indicatorMock.Setup(i => i.SetMaxValue(It.IsAny<int>())).Throws<Exception>(); indicatorMock.Setup(i => i.SetIndeterminate()).Throws<Exception>();
sut.ProgressIndicator = indicatorMock.Object; sut.ProgressIndicator = indicatorMock.Object;
var success = sut.TryRevert(); var success = sut.TryRevert();

View file

@ -12,6 +12,12 @@
<Entry key="MessageBox_ConfigureClientSuccessTitle"> <Entry key="MessageBox_ConfigureClientSuccessTitle">
Configuration Successful Configuration Successful
</Entry> </Entry>
<Entry key="MessageBox_SessionStartError">
The application failed to start a new session. Please consult the application log for more information...
</Entry>
<Entry key="MessageBox_SessionStartErrorTitle">
Session Start Error
</Entry>
<Entry key="MessageBox_ShutdownError"> <Entry key="MessageBox_ShutdownError">
An unexpected error occurred during the shutdown procedure! Please consult the application log for more information... An unexpected error occurred during the shutdown procedure! Please consult the application log for more information...
</Entry> </Entry>

View file

@ -32,7 +32,6 @@ namespace SafeExamBrowser.Runtime.Behaviour
private IServiceProxy serviceProxy; private IServiceProxy serviceProxy;
private ISplashScreen splashScreen; private ISplashScreen splashScreen;
private Action shutdown; private Action shutdown;
private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
public RuntimeController( public RuntimeController(
@ -44,7 +43,6 @@ namespace SafeExamBrowser.Runtime.Behaviour
IRuntimeInfo runtimeInfo, IRuntimeInfo runtimeInfo,
IServiceProxy serviceProxy, IServiceProxy serviceProxy,
Action shutdown, Action shutdown,
IText text,
IUserInterfaceFactory uiFactory) IUserInterfaceFactory uiFactory)
{ {
this.configuration = configuration; this.configuration = configuration;
@ -55,7 +53,6 @@ namespace SafeExamBrowser.Runtime.Behaviour
this.runtimeInfo = runtimeInfo; this.runtimeInfo = runtimeInfo;
this.serviceProxy = serviceProxy; this.serviceProxy = serviceProxy;
this.shutdown = shutdown; this.shutdown = shutdown;
this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
} }
@ -63,11 +60,13 @@ namespace SafeExamBrowser.Runtime.Behaviour
{ {
logger.Info("--- Initiating startup procedure ---"); logger.Info("--- Initiating startup procedure ---");
runtimeWindow = uiFactory.CreateRuntimeWindow(runtimeInfo, text); runtimeWindow = uiFactory.CreateRuntimeWindow(runtimeInfo);
splashScreen = uiFactory.CreateSplashScreen(runtimeInfo, text); splashScreen = uiFactory.CreateSplashScreen(runtimeInfo);
splashScreen.Show();
bootstrapSequence.ProgressIndicator = splashScreen; bootstrapSequence.ProgressIndicator = splashScreen;
sessionSequence.ProgressIndicator = runtimeWindow;
splashScreen.Show();
initialized = bootstrapSequence.TryPerform(); initialized = bootstrapSequence.TryPerform();
@ -117,10 +116,12 @@ namespace SafeExamBrowser.Runtime.Behaviour
if (success) if (success)
{ {
logger.Info("--- Application successfully finalized! ---"); logger.Info("--- Application successfully finalized! ---");
logger.Log(string.Empty);
} }
else else
{ {
logger.Info("--- Shutdown procedure failed! ---"); logger.Info("--- Shutdown procedure failed! ---");
logger.Log(string.Empty);
} }
splashScreen?.Close(); splashScreen?.Close();
@ -129,44 +130,43 @@ namespace SafeExamBrowser.Runtime.Behaviour
private void StartSession(bool initial = false) private void StartSession(bool initial = false)
{ {
logger.Info("Starting new session..."); logger.Info("Starting new session...");
runtimeWindow.UpdateText(TextKey.RuntimeWindow_StartSession, true); runtimeWindow.UpdateText(TextKey.RuntimeWindow_StartSession, true);
runtimeWindow.Show(); runtimeWindow.Show();
sessionSequence.ProgressIndicator = runtimeWindow;
// TODO:
// - Initialize configuration
// - Initialize kiosk mode
// - Initialize session data
// - Create and connect to client
// - Initialize session with service
// - Verify session integrity and start event handling
var success = initial ? sessionSequence.TryPerform() : sessionSequence.TryRepeat(); var success = initial ? sessionSequence.TryPerform() : sessionSequence.TryRepeat();
if (success) if (success)
{ {
// TODO // TODO:
// - Initialize session data
// - Create and connect to client
// - Initialize session with service
// - Verify session integrity and start event handling
runtimeWindow.HideProgressBar();
runtimeWindow.UpdateText(TextKey.RuntimeWindow_ApplicationRunning);
if (configuration.CurrentSettings.KioskMode == KioskMode.DisableExplorerShell)
{
runtimeWindow.Hide();
}
} }
else else
{ {
// TODO uiFactory.Show(TextKey.MessageBox_SessionStartError, TextKey.MessageBox_SessionStartErrorTitle, icon: MessageBoxIcon.Error);
if (initial)
{
initialized = false;
}
else
{
shutdown();
}
} }
// TODO: Remove!
System.Threading.Thread.Sleep(5000);
runtimeWindow.HideProgressBar();
runtimeWindow.UpdateText(TextKey.RuntimeWindow_ApplicationRunning);
if (configuration.CurrentSettings.KioskMode == KioskMode.DisableExplorerShell)
{
runtimeWindow.Hide();
}
// TODO: Remove!
System.Threading.Thread.Sleep(5000);
shutdown.Invoke();
} }
private void StopSession() private void StopSession()
@ -183,9 +183,6 @@ namespace SafeExamBrowser.Runtime.Behaviour
// - Stop event handling and close session // - Stop event handling and close session
var success = sessionSequence.TryRevert(); var success = sessionSequence.TryRevert();
// TODO: Remove!
System.Threading.Thread.Sleep(5000);
if (success) if (success)
{ {
// TODO // TODO

View file

@ -41,7 +41,6 @@ namespace SafeExamBrowser.Runtime
var sessionOperations = new Queue<IOperation>(); var sessionOperations = new Queue<IOperation>();
var nativeMethods = new NativeMethods(); var nativeMethods = new NativeMethods();
var configuration = new ConfigurationRepository(); var configuration = new ConfigurationRepository();
var uiFactory = new UserInterfaceFactory();
logger = new Logger(); logger = new Logger();
runtimeInfo = configuration.RuntimeInfo; runtimeInfo = configuration.RuntimeInfo;
@ -50,6 +49,7 @@ namespace SafeExamBrowser.Runtime
InitializeLogging(); InitializeLogging();
var text = new Text(logger); var text = new Text(logger);
var uiFactory = new UserInterfaceFactory(text);
var runtimeHost = new RuntimeHost(runtimeInfo.RuntimeAddress, new ModuleLogger(logger, typeof(RuntimeHost))); var runtimeHost = new RuntimeHost(runtimeInfo.RuntimeAddress, new ModuleLogger(logger, typeof(RuntimeHost)));
var serviceProxy = new ServiceProxy(runtimeInfo.ServiceAddress, new ModuleLogger(logger, typeof(ServiceProxy))); var serviceProxy = new ServiceProxy(runtimeInfo.ServiceAddress, new ModuleLogger(logger, typeof(ServiceProxy)));
@ -63,7 +63,7 @@ namespace SafeExamBrowser.Runtime
var boostrapSequence = new OperationSequence(logger, bootstrapOperations); var boostrapSequence = new OperationSequence(logger, bootstrapOperations);
var sessionSequence = new OperationSequence(logger, sessionOperations); var sessionSequence = new OperationSequence(logger, sessionOperations);
RuntimeController = new RuntimeController(configuration, logger, boostrapSequence, sessionSequence, runtimeHost, runtimeInfo, serviceProxy, Application.Current.Shutdown, text, uiFactory); RuntimeController = new RuntimeController(configuration, logger, boostrapSequence, sessionSequence, runtimeHost, runtimeInfo, serviceProxy, Application.Current.Shutdown, uiFactory);
} }
internal void LogStartupInformation() internal void LogStartupInformation()

View file

@ -22,7 +22,14 @@ namespace SafeExamBrowser.UserInterface.Classic
{ {
public class UserInterfaceFactory : IUserInterfaceFactory public class UserInterfaceFactory : IUserInterfaceFactory
{ {
public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo, IText text) private IText text;
public UserInterfaceFactory(IText text)
{
this.text = text;
}
public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo)
{ {
return new AboutWindow(runtimeInfo, text); return new AboutWindow(runtimeInfo, text);
} }
@ -37,7 +44,7 @@ namespace SafeExamBrowser.UserInterface.Classic
return new BrowserWindow(control, settings); return new BrowserWindow(control, settings);
} }
public IWindow CreateLogWindow(ILogger logger, IText text) public IWindow CreateLogWindow(ILogger logger)
{ {
LogWindow logWindow = null; LogWindow logWindow = null;
var logWindowReadyEvent = new AutoResetEvent(false); var logWindowReadyEvent = new AutoResetEvent(false);
@ -77,7 +84,7 @@ namespace SafeExamBrowser.UserInterface.Classic
return new PowerSupplyControl(); return new PowerSupplyControl();
} }
public IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo, IText text) public IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo)
{ {
RuntimeWindow runtimeWindow = null; RuntimeWindow runtimeWindow = null;
var windowReadyEvent = new AutoResetEvent(false); var windowReadyEvent = new AutoResetEvent(false);
@ -101,7 +108,7 @@ namespace SafeExamBrowser.UserInterface.Classic
return runtimeWindow; return runtimeWindow;
} }
public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo, IText text) public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo)
{ {
SplashScreen splashScreen = null; SplashScreen splashScreen = null;
var splashReadyEvent = new AutoResetEvent(false); var splashReadyEvent = new AutoResetEvent(false);
@ -140,6 +147,11 @@ namespace SafeExamBrowser.UserInterface.Classic
return ToResult(result); 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) private MessageBoxButton ToButton(MessageBoxAction action)
{ {
switch (action) switch (action)

View file

@ -21,7 +21,14 @@ namespace SafeExamBrowser.UserInterface.Windows10
{ {
public class UserInterfaceFactory : IUserInterfaceFactory public class UserInterfaceFactory : IUserInterfaceFactory
{ {
public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo, IText text) private IText text;
public UserInterfaceFactory(IText text)
{
this.text = text;
}
public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo)
{ {
return new AboutWindow(runtimeInfo, text); return new AboutWindow(runtimeInfo, text);
} }
@ -36,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Windows10
return new BrowserWindow(control, settings); return new BrowserWindow(control, settings);
} }
public IWindow CreateLogWindow(ILogger logger, IText text) public IWindow CreateLogWindow(ILogger logger)
{ {
LogWindow logWindow = null; LogWindow logWindow = null;
var logWindowReadyEvent = new AutoResetEvent(false); var logWindowReadyEvent = new AutoResetEvent(false);
@ -77,13 +84,13 @@ namespace SafeExamBrowser.UserInterface.Windows10
return new PowerSupplyControl(); return new PowerSupplyControl();
} }
public IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo, IText text) public IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo)
{ {
// TODO // TODO
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo, IText text) public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo)
{ {
SplashScreen splashScreen = null; SplashScreen splashScreen = null;
var splashReadyEvent = new AutoResetEvent(false); var splashReadyEvent = new AutoResetEvent(false);
@ -123,6 +130,11 @@ namespace SafeExamBrowser.UserInterface.Windows10
return ToResult(result); 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) private MessageBoxButton ToButton(MessageBoxAction action)
{ {
switch (action) switch (action)