seb-win-refactoring/SafeExamBrowser.Client/Operations/WindowMonitorOperation.cs

56 lines
1.5 KiB
C#
Raw Normal View History

2017-07-24 15:29:17 +02:00
/*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
2017-07-24 15:29: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/.
*/
using SafeExamBrowser.Contracts.Core.OperationModel;
2017-07-24 15:29:17 +02:00
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.Monitoring;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Client.Operations
2017-07-24 15:29:17 +02:00
{
internal class WindowMonitorOperation : IOperation
2017-07-24 15:29:17 +02:00
{
private ILogger logger;
private IWindowMonitor windowMonitor;
public IProgressIndicator ProgressIndicator { private get; set; }
2017-07-24 15:29:17 +02:00
public WindowMonitorOperation(ILogger logger, IWindowMonitor windowMonitor)
2017-07-24 15:29:17 +02:00
{
this.logger = logger;
this.windowMonitor = windowMonitor;
}
public OperationResult Perform()
2017-07-24 15:29:17 +02:00
{
logger.Info("Initializing window monitoring...");
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeWindowMonitoring);
2017-07-24 15:29:17 +02:00
windowMonitor.HideAllWindows();
windowMonitor.StartMonitoringWindows();
return OperationResult.Success;
2017-07-24 15:29:17 +02:00
}
public OperationResult Repeat()
{
return OperationResult.Success;
}
2017-07-24 15:29:17 +02:00
public void Revert()
{
logger.Info("Stopping window monitoring...");
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_StopWindowMonitoring);
2017-07-24 15:29:17 +02:00
windowMonitor.StopMonitoringWindows();
windowMonitor.RestoreHiddenWindows();
}
}
}