private void Rollback(List <HistoryMemento> historyMementos)
 {
     for (int i = historyMementos.Count - 1; i >= 0; i--)
     {
         HistoryMemento ha = historyMementos[i];
         ha.PerformUndo();
     }
 }
示例#2
0
        protected override HistoryMemento OnUndo()
        {
            List <HistoryMemento> redoActions = new List <HistoryMemento>(actions.Count);

            for (int i = 0; i < actions.Count; ++i)
            {
                HistoryMemento ha  = actions[actions.Count - i - 1];
                HistoryMemento rha = null;

                if (ha != null)
                {
                    rha = ha.PerformUndo();
                }

                redoActions.Add(rha);
            }

            CompoundHistoryMemento cha = new CompoundHistoryMemento(Name, Image, redoActions);

            return(cha);
        }
示例#3
0
 private void CancelDrawing()
 {
     ((TransactedTool <TDerived, TChanges>) this).VerifyAccess <TransactedTool <TDerived, TChanges> >();
     if (this.State != TransactedToolState.Drawing)
     {
         throw new InvalidOperationException($"Can only CancelDrawing when State is Drawing (State={this.State}, Tool={base.GetType().Name})");
     }
     if (!this.drawingAgent.TransactionToken.IsCanceling)
     {
         this.drawingAgent.TransactionToken.Cancel();
     }
     else
     {
         this.OnCancelingDrawing();
         this.drawingAgent.TransactionToken = null;
         this.drawingAgent = null;
         this.SetState(TransactedToolState.Idle);
         this.Changes = default(TChanges);
         HistoryMemento beforeDrawingMemento = this.beforeDrawingMemento;
         this.beforeDrawingMemento = null;
         beforeDrawingMemento.PerformUndo(null);
     }
 }