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

52 lines
1.5 KiB
C#
Raw Permalink Normal View History

2017-08-04 12:19:56 +02:00
/*
* Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET)
2017-08-04 12:19:56 +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.Core.Contracts.OperationModel;
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Monitoring.Contracts.Mouse;
2017-08-04 12:19:56 +02:00
namespace SafeExamBrowser.Client.Operations
2017-08-04 12:19:56 +02:00
{
internal class MouseInterceptorOperation : ClientOperation
2017-08-04 12:19:56 +02:00
{
private ILogger logger;
2017-08-04 15:20:33 +02:00
private IMouseInterceptor mouseInterceptor;
2017-08-04 12:19:56 +02:00
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
public override event StatusChangedEventHandler StatusChanged;
public MouseInterceptorOperation(ClientContext context, ILogger logger, IMouseInterceptor mouseInterceptor) : base(context)
2017-08-04 12:19:56 +02:00
{
this.logger = logger;
2017-08-04 15:20:33 +02:00
this.mouseInterceptor = mouseInterceptor;
2017-08-04 12:19:56 +02:00
}
public override OperationResult Perform()
2017-08-04 12:19:56 +02:00
{
logger.Info("Starting mouse interception...");
StatusChanged?.Invoke(TextKey.OperationStatus_StartMouseInterception);
2017-08-04 12:19:56 +02:00
mouseInterceptor.Start();
return OperationResult.Success;
2017-08-04 12:19:56 +02:00
}
public override OperationResult Revert()
2017-08-04 12:19:56 +02:00
{
logger.Info("Stopping mouse interception...");
StatusChanged?.Invoke(TextKey.OperationStatus_StopMouseInterception);
2017-08-04 12:19:56 +02:00
mouseInterceptor.Stop();
return OperationResult.Success;
2017-08-04 12:19:56 +02:00
}
}
}