2018-06-22 18:31:55 +02:00
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using Windows.UI.Xaml;
|
2018-06-21 18:40:44 +02:00
|
|
|
|
using Microsoft.Xaml.Interactivity;
|
|
|
|
|
using ModernKeePass.Common;
|
|
|
|
|
using ModernKeePass.Interfaces;
|
|
|
|
|
using ModernKeePass.Services;
|
|
|
|
|
using ModernKeePass.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Actions
|
|
|
|
|
{
|
|
|
|
|
public class RestoreEntityAction : DependencyObject, IAction
|
|
|
|
|
{
|
|
|
|
|
public IPwEntity Entity
|
|
|
|
|
{
|
|
|
|
|
get { return (IPwEntity)GetValue(EntityProperty); }
|
|
|
|
|
set { SetValue(EntityProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty EntityProperty =
|
|
|
|
|
DependencyProperty.Register("Entity", typeof(IPwEntity), typeof(RestoreEntityAction),
|
|
|
|
|
new PropertyMetadata(null));
|
2018-06-22 18:31:55 +02:00
|
|
|
|
|
|
|
|
|
public ICommand Command
|
2018-06-21 18:40:44 +02:00
|
|
|
|
{
|
2018-06-22 18:31:55 +02:00
|
|
|
|
get { return (ICommand)GetValue(CommandProperty); }
|
|
|
|
|
set { SetValue(CommandProperty, value); }
|
2018-06-21 18:40:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 18:31:55 +02:00
|
|
|
|
public static readonly DependencyProperty CommandProperty =
|
|
|
|
|
DependencyProperty.Register("Command", typeof(ICommand), typeof(RestoreEntityAction),
|
2018-06-21 18:40:44 +02:00
|
|
|
|
new PropertyMetadata(null));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public object Execute(object sender, object parameter)
|
|
|
|
|
{
|
|
|
|
|
var resource = new ResourcesService();
|
|
|
|
|
var type = Entity is GroupVm ? "Group" : "Entry";
|
|
|
|
|
|
|
|
|
|
ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityRestoredTitle"),
|
|
|
|
|
resource.GetResourceValue($"{type}Restored"));
|
2018-06-22 18:31:55 +02:00
|
|
|
|
Command.Execute(null);
|
2018-06-21 18:40:44 +02:00
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|