2017-07-21 10:04:27 +02:00
|
|
|
|
/*
|
|
|
|
|
* 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 SafeExamBrowser.Contracts.Behaviour;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
using SafeExamBrowser.Core.Notifications;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.Core.Behaviour.Operations
|
|
|
|
|
{
|
2017-07-26 14:36:20 +02:00
|
|
|
|
public class TaskbarOperation : IOperation
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
|
|
|
|
private ILogger logger;
|
2017-08-07 12:23:56 +02:00
|
|
|
|
private INotificationController aboutController, logController;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
private ITaskbar taskbar;
|
2017-07-27 14:45:54 +02:00
|
|
|
|
private IUserInterfaceFactory uiFactory;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
private IText text;
|
|
|
|
|
private ISettings settings;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
|
|
|
|
public ISplashScreen SplashScreen { private get; set; }
|
|
|
|
|
|
2017-08-07 12:23:56 +02:00
|
|
|
|
public TaskbarOperation(
|
|
|
|
|
ILogger logger,
|
|
|
|
|
ISettings settings,
|
|
|
|
|
ITaskbar taskbar,
|
|
|
|
|
IText text,
|
|
|
|
|
IUserInterfaceFactory uiFactory)
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
|
|
|
|
this.logger = logger;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
this.settings = settings;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
this.taskbar = taskbar;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
this.text = text;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
this.uiFactory = uiFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Perform()
|
|
|
|
|
{
|
2017-07-24 15:29:17 +02:00
|
|
|
|
logger.Info("Initializing taskbar...");
|
2017-08-03 15:35:22 +02:00
|
|
|
|
SplashScreen.UpdateText(TextKey.SplashScreen_InitializeTaskbar);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2017-08-07 12:23:56 +02:00
|
|
|
|
if (settings.AllowApplicationLog)
|
|
|
|
|
{
|
|
|
|
|
CreateLogNotification();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CreateAboutNotification();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Revert()
|
|
|
|
|
{
|
|
|
|
|
logController?.Terminate();
|
|
|
|
|
aboutController.Terminate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CreateAboutNotification()
|
|
|
|
|
{
|
2017-08-02 10:13:23 +02:00
|
|
|
|
var aboutInfo = new AboutNotificationInfo(text);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
var aboutNotification = uiFactory.CreateNotification(aboutInfo);
|
|
|
|
|
|
2017-08-02 10:13:23 +02:00
|
|
|
|
aboutController = new AboutNotificationController(settings, text, uiFactory);
|
|
|
|
|
aboutController.RegisterNotification(aboutNotification);
|
|
|
|
|
|
2017-07-21 10:04:27 +02:00
|
|
|
|
taskbar.AddNotification(aboutNotification);
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-07 12:23:56 +02:00
|
|
|
|
private void CreateLogNotification()
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-08-07 12:23:56 +02:00
|
|
|
|
var logInfo = new LogNotificationInfo(text);
|
|
|
|
|
var logNotification = uiFactory.CreateNotification(logInfo);
|
|
|
|
|
|
2017-08-11 10:22:09 +02:00
|
|
|
|
logController = new LogNotificationController(logger, text, uiFactory);
|
2017-08-07 12:23:56 +02:00
|
|
|
|
logController.RegisterNotification(logNotification);
|
|
|
|
|
|
|
|
|
|
taskbar.AddNotification(logNotification);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|