2017-08-07 18:08:55 +02:00
|
|
|
|
/*
|
2020-01-06 15:24:46 +01:00
|
|
|
|
* Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET)
|
2017-08-07 18:08:55 +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.WindowsApi.Contracts;
|
2017-08-07 18:08:55 +02:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Client.Operations
|
2017-08-07 18:08:55 +02:00
|
|
|
|
{
|
2019-10-01 16:24:10 +02:00
|
|
|
|
internal class ClipboardOperation : ClientOperation
|
2017-08-07 18:08:55 +02:00
|
|
|
|
{
|
|
|
|
|
private ILogger logger;
|
|
|
|
|
private INativeMethods nativeMethods;
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
|
|
|
public override event StatusChangedEventHandler StatusChanged;
|
2017-08-07 18:08:55 +02:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public ClipboardOperation(ClientContext context, ILogger logger, INativeMethods nativeMethods) : base(context)
|
2017-08-07 18:08:55 +02:00
|
|
|
|
{
|
|
|
|
|
this.logger = logger;
|
|
|
|
|
this.nativeMethods = nativeMethods;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override OperationResult Perform()
|
2017-08-07 18:08:55 +02:00
|
|
|
|
{
|
|
|
|
|
EmptyClipboard();
|
2018-02-28 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-08-07 18:08:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override OperationResult Revert()
|
2017-08-07 18:08:55 +02:00
|
|
|
|
{
|
|
|
|
|
EmptyClipboard();
|
2018-10-10 09:19:03 +02:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-08-07 18:08:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EmptyClipboard()
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Emptying clipboard...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_EmptyClipboard);
|
2017-08-07 18:08:55 +02:00
|
|
|
|
|
|
|
|
|
nativeMethods.EmptyClipboard();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|