Пример #1
0
        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);
        }
Пример #2
0
        public IListTOfVMemento <T, U> Restore(T target)
        {
            var returnMemento = new MoveItemDownMemento <T, U>(_child, _index + 1);

            target.Move(_index, _index + 1);


            return(returnMemento);
        }