Ejemplo n.º 1
0
        public void Undo()
        {
            if (!CanUndo)
            {
                throw new InvalidOperationException("Undo stack is empty");
            }

            var memento = undoStack.Pop();

            changeTracker.TrackChanges = false;

            changeTracker.OnBeforeUndo(memento);

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

            memento = memento.Restore();

            redoStack.Push(memento);

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

            changeTracker.TrackChanges = trackChanges;
        }
Ejemplo n.º 2
0
        public void Undo()
        {
            if (!CanUndo)
            {
                throw new InvalidOperationException("Undo stack is empty");
            }

            var memento = undoStack.Pop();

            changeTracker.AddNewMementoCallback = AddRedo;

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

            changeTracker.OnBeforeUndo(memento);

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

            changeTracker.OnAfterUndo(memento);

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

            changeTracker.AddNewMementoCallback = AddUndo;
        }