Exemple #1
0
        private void StepForwardImpl()
        {
            HistoryMemento     topMemento           = redoStack[0];
            ToolHistoryMemento asToolHistoryMemento = topMemento as ToolHistoryMemento;

            if (asToolHistoryMemento != null && asToolHistoryMemento.ToolType != this.documentWorkspace.GetToolType())
            {
                this.documentWorkspace.SetToolFromType(asToolHistoryMemento.ToolType);
                StepForward();
            }
            else
            {
                OnChanging();

                ExecutingHistoryMementoEventArgs ehaea1 = new ExecutingHistoryMementoEventArgs(topMemento, true, false);

                if (asToolHistoryMemento == null && topMemento.SeriesGuid != Guid.Empty)
                {
                    ehaea1.SuspendTool = true;
                }

                OnExecutingHistoryMemento(ehaea1);

                if (ehaea1.SuspendTool)
                {
                    this.documentWorkspace.PushNullTool();
                }

                HistoryMemento redoMemento = redoStack[0];

                // Possibly useful invariant here:
                //     ehaea1.HistoryMemento.SeriesGuid == ehaea2.HistoryMemento.SeriesGuid == ehaea3.HistoryMemento.SeriesGuid
                ExecutingHistoryMementoEventArgs ehaea2 = new ExecutingHistoryMementoEventArgs(redoMemento, false, ehaea1.SuspendTool);
                OnExecutingHistoryMemento(ehaea2);

                HistoryMemento undoMemento = redoMemento.PerformUndo();

                redoStack.RemoveAt(0);
                undoStack.Add(undoMemento);

                ExecutedHistoryMementoEventArgs ehaea3 = new ExecutedHistoryMementoEventArgs(undoMemento);
                OnExecutedHistoryMemento(ehaea3);

                OnChanged();
                OnSteppedForward();

                undoMemento.Flush();

                if (ehaea1.SuspendTool)
                {
                    this.documentWorkspace.PopNullTool();
                }
            }

            if (this.stepGroupDepth == 0)
            {
                OnFinishedStepGroup();
            }
        }
Exemple #2
0
        private void StepForwardImpl(IWin32Window owner)
        {
            HistoryMemento     historyMemento = this.redoStack[0];
            ToolHistoryMemento memento2       = historyMemento as ToolHistoryMemento;

            if ((memento2 != null) && (memento2.ToolType != this.documentWorkspace.GetToolType()))
            {
                this.documentWorkspace.SetToolFromType(memento2.ToolType);
                this.StepForwardImpl(owner);
            }
            else
            {
                this.OnChanging();
                ExecutingHistoryMementoEventArgs e = new ExecutingHistoryMementoEventArgs(historyMemento, true, false);
                if ((memento2 == null) && (historyMemento.SeriesGuid != Guid.Empty))
                {
                    e.SuspendTool = true;
                }
                this.OnExecutingHistoryMemento(e);
                if (e.SuspendTool)
                {
                    this.documentWorkspace.PushNullTool();
                }
                HistoryMemento memento3 = this.redoStack[0];
                ExecutingHistoryMementoEventArgs args2 = new ExecutingHistoryMementoEventArgs(memento3, false, e.SuspendTool);
                this.OnExecutingHistoryMemento(args2);
                using (this.disallowPushNewMementoRegion.UseEnterScope())
                {
                    HistoryMemento item = memento3.PerformUndo(null);
                    this.redoStack.RemoveAt(0);
                    this.undoStack.Add(item);
                    ExecutedHistoryMementoEventArgs args3 = new ExecutedHistoryMementoEventArgs(item);
                    this.OnExecutedHistoryMemento(args3);
                    this.OnChanged();
                    this.OnSteppedForward();
                    item.Flush();
                }
                if (e.SuspendTool)
                {
                    this.documentWorkspace.PopNullTool();
                }
            }
            if (this.stepGroupDepth == 0)
            {
                this.OnFinishedStepGroup();
            }
        }
Exemple #3
0
        private void StepBackwardImpl(IWin32Window owner)
        {
            HistoryMemento     historyMemento = this.undoStack[this.undoStack.Count - 1];
            ToolHistoryMemento memento2       = historyMemento as ToolHistoryMemento;

            if ((memento2 != null) && (memento2.ToolType != this.documentWorkspace.GetToolType()))
            {
                this.documentWorkspace.SetToolFromType(memento2.ToolType);
                this.StepBackwardImpl(owner);
            }
            else
            {
                this.OnChanging();
                ExecutingHistoryMementoEventArgs e = new ExecutingHistoryMementoEventArgs(historyMemento, true, false);
                if ((memento2 == null) && (historyMemento.SeriesGuid == Guid.Empty))
                {
                    e.SuspendTool = true;
                }
                this.OnExecutingHistoryMemento(e);
                ReferenceValue changes = null;
                System.Type    type    = null;
                if (e.SuspendTool)
                {
                    TransactedTool tool = this.documentWorkspace.Tool as TransactedTool;
                    if (tool != null)
                    {
                        type = tool.GetType();
                        tool.ForceCancelDrawingOrEditing();
                        if (tool.State == TransactedToolState.Dirty)
                        {
                            changes = tool.Changes;
                            tool.CancelChanges();
                        }
                    }
                    this.documentWorkspace.PushNullTool();
                }
                HistoryMemento memento3 = this.undoStack[this.undoStack.Count - 1];
                ExecutingHistoryMementoEventArgs args2 = new ExecutingHistoryMementoEventArgs(memento3, false, e.SuspendTool);
                this.OnExecutingHistoryMemento(args2);
                using (this.disallowPushNewMementoRegion.UseEnterScope())
                {
                    HistoryMemento item = this.undoStack[this.undoStack.Count - 1].PerformUndo(null);
                    this.undoStack.RemoveAt(this.undoStack.Count - 1);
                    this.redoStack.Insert(0, item);
                    ExecutedHistoryMementoEventArgs args3 = new ExecutedHistoryMementoEventArgs(item);
                    this.OnExecutedHistoryMemento(args3);
                    this.OnChanged();
                    this.OnSteppedBackward();
                    item.Flush();
                }
                if (e.SuspendTool)
                {
                    this.documentWorkspace.PopNullTool();
                    if (changes != null)
                    {
                        ((TransactedTool)this.documentWorkspace.Tool).RestoreChanges(changes);
                    }
                }
            }
            if (this.stepGroupDepth == 0)
            {
                this.OnFinishedStepGroup();
            }
        }