mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
28 lines
907 B
C#
28 lines
907 B
C#
using Windows.ApplicationModel.DataTransfer;
|
|
using Windows.UI.Xaml;
|
|
using Microsoft.Xaml.Interactivity;
|
|
|
|
namespace ModernKeePass.Actions
|
|
{
|
|
public class ClipboardAction : DependencyObject, IAction
|
|
{
|
|
public string Text
|
|
{
|
|
get => (string)GetValue(TextProperty);
|
|
set => SetValue(TextProperty, value);
|
|
}
|
|
|
|
public static readonly DependencyProperty TextProperty =
|
|
DependencyProperty.Register("Text", typeof(string), typeof(ClipboardAction), new PropertyMetadata(string.Empty));
|
|
|
|
public object Execute(object sender, object parameter)
|
|
{
|
|
if (string.IsNullOrEmpty(Text)) return null;
|
|
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
|
|
dataPackage.SetText(Text);
|
|
Clipboard.SetContent(dataPackage);
|
|
return null;
|
|
}
|
|
}
|
|
}
|