mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Clipboard action now sets an expiration timer
WIP Max History count (back-end done, front-end todo)
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using System;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.UI.Xaml;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.Actions
|
||||
{
|
||||
public class ClipboardAction : DependencyObject, IAction
|
||||
{
|
||||
private DispatcherTimer _dispatcher;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return (string)GetValue(TextProperty); }
|
||||
@@ -18,10 +24,24 @@ namespace ModernKeePass.Actions
|
||||
public object Execute(object sender, object parameter)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text)) return null;
|
||||
|
||||
var settings = App.Services.GetRequiredService<ISettingsProxy>();
|
||||
|
||||
_dispatcher = new DispatcherTimer {Interval = TimeSpan.FromSeconds(settings.GetSetting(Constants.Settings.ClipboardTimeout, 10))};
|
||||
_dispatcher.Tick += Dispatcher_Tick;
|
||||
|
||||
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
|
||||
dataPackage.SetText(Text);
|
||||
Clipboard.SetContent(dataPackage);
|
||||
_dispatcher.Start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Dispatcher_Tick(object sender, object e)
|
||||
{
|
||||
Clipboard.SetContent(null);
|
||||
_dispatcher.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@
|
||||
public static string SaveSuspend => nameof(SaveSuspend);
|
||||
public static string Sample => nameof(Sample);
|
||||
public static string DefaultFileFormat => nameof(DefaultFileFormat);
|
||||
public static string ClipboardTimeout => nameof(ClipboardTimeout);
|
||||
public static string HistoryMaxCount => nameof(HistoryMaxCount);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user