예제 #1
0
        public void Redo()
        {
            if (!CanRedo)
            {
                throw new InvalidOperationException("Redo stack is empty");
            }

            var memento = redoStack.Pop();

            changeTracker.TrackChanges = false;

            changeTracker.OnBeforeRedo(memento);

            if (BeforeRedo != null)
            {
                BeforeRedo(this, new UndoRedoEventArgs {
                    Memento = memento
                });
            }

            memento = memento.Restore();

            undoStack.Push(memento);

            if (AfterRedo != null)
            {
                AfterRedo(this, new UndoRedoEventArgs {
                    Memento = memento
                });
            }

            changeTracker.TrackChanges = trackChanges;
        }
예제 #2
0
        public void Redo()
        {
            if (!CanRedo)
            {
                throw new InvalidOperationException("Redo stack is empty");
            }

            var memento = redoStack.Pop();

            changeTracker.AddNewMementoCallback = AddUndoForRedo;

            if (BeforeRedo != null)
            {
                BeforeRedo(this, new UndoRedoEventArgs {
                    Memento = memento
                });
            }

            changeTracker.OnBeforeRedo(memento);

            try
            {
                EditActionSettings.Disabled = true;
                memento.Restore();
            }
            finally
            {
                EditActionSettings.Disabled = false;
            }

            changeTracker.OnAfterRedo(memento);

            if (AfterRedo != null)
            {
                AfterRedo(this, new UndoRedoEventArgs {
                    Memento = memento
                });
            }

            changeTracker.AddNewMementoCallback = AddUndo;
        }