2017-07-21 10:04:27 +02:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
2017-07-21 10:04:27 +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/.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
|
|
|
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
|
|
|
|
using SafeExamBrowser.I18n.Contracts;
|
|
|
|
|
using SafeExamBrowser.Logging.Contracts;
|
|
|
|
|
using SafeExamBrowser.Monitoring.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Shell;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Client.Operations
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2018-01-18 08:16:20 +01:00
|
|
|
|
internal class DisplayMonitorOperation : IOperation
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-08-11 08:28:17 +02:00
|
|
|
|
private IDisplayMonitor displayMonitor;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
private ILogger logger;
|
|
|
|
|
private ITaskbar taskbar;
|
|
|
|
|
|
2018-10-03 14:35:27 +02:00
|
|
|
|
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
|
|
|
public event StatusChangedEventHandler StatusChanged;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2017-08-11 08:28:17 +02:00
|
|
|
|
public DisplayMonitorOperation(IDisplayMonitor displayMonitor, ILogger logger, ITaskbar taskbar)
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-08-11 08:28:17 +02:00
|
|
|
|
this.displayMonitor = displayMonitor;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
this.logger = logger;
|
|
|
|
|
this.taskbar = taskbar;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 15:49:06 +01:00
|
|
|
|
public OperationResult Perform()
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-07-24 15:29:17 +02:00
|
|
|
|
logger.Info("Initializing working area...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeWorkingArea);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2017-08-11 11:16:44 +02:00
|
|
|
|
displayMonitor.PreventSleepMode();
|
2017-08-11 08:28:17 +02:00
|
|
|
|
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
|
|
|
|
displayMonitor.StartMonitoringDisplayChanges();
|
2018-02-28 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-10 09:19:03 +02:00
|
|
|
|
public OperationResult Revert()
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-07-24 15:29:17 +02:00
|
|
|
|
logger.Info("Restoring working area...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_RestoreWorkingArea);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2017-08-11 08:28:17 +02:00
|
|
|
|
displayMonitor.StopMonitoringDisplayChanges();
|
|
|
|
|
displayMonitor.ResetPrimaryDisplay();
|
2018-10-10 09:19:03 +02:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|