public IListTOfVMemento <T, U> Restore(T target) { var returnMemento = new PropertyChangedMemento <T, U, V>(_child, _propertyInfo, _value); _child.RestorePropertyInternal(_propertyInfo, _value); return(returnMemento); }
private void Button_Click(object sender, RoutedEventArgs e) { Int32 ordinal = Int32.Parse(((Button)sender).Tag.ToString()); var current = Persons.First(p => p.Ordinal == ordinal); var below = Persons.First(p => p.Ordinal == ordinal + 1); _undoRedoHistory.BeginCompoundDo(0); // Passing in zero to get the first memento pointer back PropertyChangedMemento <PersonList, Person, int> MoveDownPropertyChangedMemento = new PropertyChangedMemento <PersonList, Person, int>(current, Person.PropertyOrdinal, current.Ordinal); PropertyChangedMemento <PersonList, Person, int> MoveUpPropertyChangedMemento = new PropertyChangedMemento <PersonList, Person, int>(below, Person.PropertyOrdinal, below.Ordinal); MoveItemDownMemento <PersonList, Person> moveItemDownMemento = new MoveItemDownMemento <PersonList, Person>(current, ordinal + 1); _undoRedoHistory.CheckPoint(MoveDownPropertyChangedMemento); _undoRedoHistory.CheckPoint(MoveUpPropertyChangedMemento); _undoRedoHistory.CheckPoint(moveItemDownMemento); _undoRedoHistory.EndCompoundDo(); current.Ordinal = ordinal + 1; below.Ordinal = ordinal; Persons.Move(ordinal, ordinal + 1); DataGrid1.ScrollIntoView(current); }
private void TextBox_GotFocus(object sender, RoutedEventArgs e) { _textAtGotFocus = ((TextBox)sender).Text; var selectedItem = ((TextBox)sender).Tag as Person; if (selectedItem is null) { return; } PropertyChangedMemento <PersonList, Person, String> personPropertyChangedMemento = new PropertyChangedMemento <PersonList, Person, String>(selectedItem, Person.PropertyDescription, selectedItem.Description); _undoRedoHistory.CheckPoint(personPropertyChangedMemento); }
private void ButtonDelete_Click(object sender, RoutedEventArgs e) { Person selectedItem = ((Button)sender).Tag as Person; if (selectedItem.Deleted) { return; } PropertyChangedMemento <PersonList, Person, Boolean> personPropertyChangedMemento = new PropertyChangedMemento <PersonList, Person, Boolean>(selectedItem, Person.PropertyDeleted, selectedItem.Deleted); _undoRedoHistory.CheckPoint(personPropertyChangedMemento); selectedItem.Deleted = true; }