void IDragSource.DragDropOperationFinished(DragDropEffects operationResult, IDragInfo dragInfo) { // will always called even if operation failed Log.Info("DragDropOperationFinished"); _mementoService.EndBatch(); if (!_operationSuccessFul) { Log.Info("call undo"); _mementoService.Undo(); } }
/// <summary> /// Initializes a new instance of the <see cref="PersonViewModel"/> class. /// </summary> /// <param name="person">The person.</param> public PersonViewModel(Person person, IMementoService mementoService) { _mementoService = mementoService; Person = person ?? new Person(); Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo); Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo); GenerateData = new Command<object, object>(OnGenerateDataExecute, OnGenerateDataCanExecute); ToggleCustomError = new Command<object>(OnToggleCustomErrorExecute); _mementoService.RegisterObject(this); }
/// <summary> /// Initializes a new instance of the <see cref="PersonViewModel"/> class. /// </summary> /// <param name="person">The person.</param> public PersonViewModel(Person person, IMementoService mementoService) { _mementoService = mementoService; Person = person ?? new Person(); Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo); Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo); GenerateData = new Command <object, object>(OnGenerateDataExecute, OnGenerateDataCanExecute); ToggleCustomError = new Command <object>(OnToggleCustomErrorExecute); _mementoService.RegisterObject(this); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IUIVisualizerService uiVisualizerService, IMessageService messageService, IMementoService mementoService) { _uiVisualizerService = uiVisualizerService; _messageService = messageService; _mementoService = mementoService; Add = new TaskCommand(OnAddExecuteAsync); Edit = new TaskCommand(OnEditExecuteAsync, OnEditCanExecute); Remove = new TaskCommand(OnRemoveExecuteAsync, OnRemoveCanExecute); Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo); Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo); PersonCollection = new ObservableCollection<Person> {new Person {Gender = Gender.Male, FirstName = "Geert", MiddleName = "van", LastName = "Horrik"}, new Person {Gender = Gender.Male, FirstName = "Fred", MiddleName = "", LastName = "Retteket"}}; _mementoService.RegisterCollection(PersonCollection); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IUIVisualizerService uiVisualizerService, IMessageService messageService, IMementoService mementoService) { _uiVisualizerService = uiVisualizerService; _messageService = messageService; _mementoService = mementoService; Add = new Command(OnAddExecute); Edit = new Command(OnEditExecute, OnEditCanExecute); Remove = new Command(OnRemoveExecute, OnRemoveCanExecute); Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo); Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo); PersonCollection = new ObservableCollection <Person> { new Person { Gender = Gender.Male, FirstName = "Geert", MiddleName = "van", LastName = "Horrik" }, new Person { Gender = Gender.Male, FirstName = "Fred", MiddleName = "", LastName = "Retteket" } }; _mementoService.RegisterCollection(PersonCollection); }