2017-08-22 09:37:17 +02:00
|
|
|
|
/*
|
2018-01-16 08:24:00 +01:00
|
|
|
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
2017-08-22 09:37:17 +02:00
|
|
|
|
*
|
|
|
|
|
* 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/.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-08-22 10:29:00 +02:00
|
|
|
|
using System.Threading;
|
2018-07-04 09:53:33 +02:00
|
|
|
|
using System.Windows;
|
2017-08-22 09:37:17 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
|
|
|
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2018-03-14 12:07:20 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
2017-08-22 09:37:17 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
2018-03-14 12:07:20 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Windows;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Classic.Controls;
|
2017-08-22 09:37:17 +02:00
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.UserInterface.Classic
|
|
|
|
|
{
|
|
|
|
|
public class UserInterfaceFactory : IUserInterfaceFactory
|
|
|
|
|
{
|
2018-02-07 13:25:49 +01:00
|
|
|
|
private IText text;
|
|
|
|
|
|
|
|
|
|
public UserInterfaceFactory(IText text)
|
|
|
|
|
{
|
|
|
|
|
this.text = text;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 09:50:20 +02:00
|
|
|
|
public IWindow CreateAboutWindow(AppConfig appConfig)
|
2017-08-22 09:37:17 +02:00
|
|
|
|
{
|
2018-06-29 09:50:20 +02:00
|
|
|
|
return new AboutWindow(appConfig, text);
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IApplicationButton CreateApplicationButton(IApplicationInfo info)
|
|
|
|
|
{
|
2017-08-22 10:29:00 +02:00
|
|
|
|
return new ApplicationButton(info);
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-15 15:42:54 +01:00
|
|
|
|
public IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings)
|
2017-08-22 09:37:17 +02:00
|
|
|
|
{
|
2017-08-22 10:29:00 +02:00
|
|
|
|
return new BrowserWindow(control, settings);
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-27 14:02:16 +02:00
|
|
|
|
public ISystemKeyboardLayoutControl CreateKeyboardLayoutControl()
|
|
|
|
|
{
|
|
|
|
|
return new KeyboardLayoutControl();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-07 13:25:49 +01:00
|
|
|
|
public IWindow CreateLogWindow(ILogger logger)
|
2017-08-22 09:37:17 +02:00
|
|
|
|
{
|
2017-08-22 10:58:36 +02:00
|
|
|
|
LogWindow logWindow = null;
|
|
|
|
|
var logWindowReadyEvent = new AutoResetEvent(false);
|
|
|
|
|
var logWindowThread = new Thread(() =>
|
|
|
|
|
{
|
|
|
|
|
logWindow = new LogWindow(logger, text);
|
|
|
|
|
logWindow.Closed += (o, args) => logWindow.Dispatcher.InvokeShutdown();
|
|
|
|
|
logWindow.Show();
|
|
|
|
|
|
|
|
|
|
logWindowReadyEvent.Set();
|
|
|
|
|
|
|
|
|
|
System.Windows.Threading.Dispatcher.Run();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
logWindowThread.SetApartmentState(ApartmentState.STA);
|
|
|
|
|
logWindowThread.IsBackground = true;
|
|
|
|
|
logWindowThread.Start();
|
|
|
|
|
|
|
|
|
|
logWindowReadyEvent.WaitOne();
|
|
|
|
|
|
|
|
|
|
return logWindow;
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public INotificationButton CreateNotification(INotificationInfo info)
|
|
|
|
|
{
|
2017-08-22 10:29:00 +02:00
|
|
|
|
return new NotificationButton(info);
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-27 14:02:16 +02:00
|
|
|
|
public IPasswordDialog CreatePasswordDialog(string message, string title)
|
2017-09-13 08:33:12 +02:00
|
|
|
|
{
|
2018-07-04 09:53:33 +02:00
|
|
|
|
return Application.Current.Dispatcher.Invoke(() => new PasswordDialog(message, title, text));
|
2017-09-13 08:33:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-22 09:37:17 +02:00
|
|
|
|
public ISystemPowerSupplyControl CreatePowerSupplyControl()
|
|
|
|
|
{
|
2017-08-23 10:30:27 +02:00
|
|
|
|
return new PowerSupplyControl();
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 09:50:20 +02:00
|
|
|
|
public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig)
|
2018-01-30 14:41:36 +01:00
|
|
|
|
{
|
|
|
|
|
RuntimeWindow runtimeWindow = null;
|
|
|
|
|
var windowReadyEvent = new AutoResetEvent(false);
|
|
|
|
|
var runtimeWindowThread = new Thread(() =>
|
|
|
|
|
{
|
2018-08-16 11:23:37 +02:00
|
|
|
|
runtimeWindow = new RuntimeWindow(appConfig, text);
|
2018-01-30 14:41:36 +01:00
|
|
|
|
runtimeWindow.Closed += (o, args) => runtimeWindow.Dispatcher.InvokeShutdown();
|
|
|
|
|
|
|
|
|
|
windowReadyEvent.Set();
|
|
|
|
|
|
|
|
|
|
System.Windows.Threading.Dispatcher.Run();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
runtimeWindowThread.SetApartmentState(ApartmentState.STA);
|
|
|
|
|
runtimeWindowThread.Name = nameof(RuntimeWindow);
|
|
|
|
|
runtimeWindowThread.IsBackground = true;
|
|
|
|
|
runtimeWindowThread.Start();
|
|
|
|
|
|
|
|
|
|
windowReadyEvent.WaitOne();
|
|
|
|
|
|
|
|
|
|
return runtimeWindow;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 09:50:20 +02:00
|
|
|
|
public ISplashScreen CreateSplashScreen(AppConfig appConfig = null)
|
2017-08-22 09:37:17 +02:00
|
|
|
|
{
|
2017-08-22 10:29:00 +02:00
|
|
|
|
SplashScreen splashScreen = null;
|
|
|
|
|
var splashReadyEvent = new AutoResetEvent(false);
|
|
|
|
|
var splashScreenThread = new Thread(() =>
|
|
|
|
|
{
|
2018-06-29 09:50:20 +02:00
|
|
|
|
splashScreen = new SplashScreen(text, appConfig);
|
2017-08-22 10:29:00 +02:00
|
|
|
|
splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown();
|
|
|
|
|
splashScreen.Show();
|
|
|
|
|
|
|
|
|
|
splashReadyEvent.Set();
|
|
|
|
|
|
|
|
|
|
System.Windows.Threading.Dispatcher.Run();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
splashScreenThread.SetApartmentState(ApartmentState.STA);
|
|
|
|
|
splashScreenThread.Name = nameof(SplashScreen);
|
|
|
|
|
splashScreenThread.IsBackground = true;
|
|
|
|
|
splashScreenThread.Start();
|
|
|
|
|
|
|
|
|
|
splashReadyEvent.WaitOne();
|
|
|
|
|
|
|
|
|
|
return splashScreen;
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 10:26:30 +01:00
|
|
|
|
public ISystemWirelessNetworkControl CreateWirelessNetworkControl()
|
|
|
|
|
{
|
|
|
|
|
return new WirelessNetworkControl();
|
|
|
|
|
}
|
2017-08-22 09:37:17 +02:00
|
|
|
|
}
|
|
|
|
|
}
|