2017-07-21 10:04:27 +02:00
|
|
|
|
/*
|
2021-02-03 00:45:33 +01:00
|
|
|
|
* Copyright (c) 2021 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;
|
2019-09-05 09:00:41 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Contracts.Display;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
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
|
|
|
|
{
|
2019-10-01 16:24:10 +02:00
|
|
|
|
internal class DisplayMonitorOperation : ClientOperation
|
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;
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
|
|
|
public override event StatusChangedEventHandler StatusChanged;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public DisplayMonitorOperation(ClientContext context, IDisplayMonitor displayMonitor, ILogger logger, ITaskbar taskbar) : base(context)
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override 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();
|
2020-02-21 09:38:39 +01:00
|
|
|
|
displayMonitor.InitializePrimaryDisplay(Context.Settings.Taskbar.EnableTaskbar ? taskbar.GetAbsoluteHeight() : 0);
|
2017-08-11 08:28:17 +02:00
|
|
|
|
displayMonitor.StartMonitoringDisplayChanges();
|
2018-02-28 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|