Beispiel #1
0
 protected UndoItem(string description, object target, UndoItem.TransactionState state = UndoItem.TransactionState.None)
 {
     this.Target = target;
       this.Description = description;
       this.State = state;
       this.isCommitted = state == UndoItem.TransactionState.None || state == UndoItem.TransactionState.Commit;
       if (this.State != UndoItem.TransactionState.Begin)
     return;
       this.TransactionList = new List<UndoItem>();
 }
Beispiel #2
0
 internal bool AddTransactionItem(UndoItem item)
 {
     if (item.State == UndoItem.TransactionState.Begin || item.State == UndoItem.TransactionState.None)
     throw new ArgumentException("Undo item must be of type Commit or Payload in order to be added to the current undo transaction.");
       if (this.isCommitted)
     throw new ArgumentException("Undo item can not be added to a undo transaction in committed state.");
       if (item.State == UndoItem.TransactionState.Commit)
       {
     this.Description = item.Description;
     this.isCommitted = true;
     this.TransactionList.ForEach((Action<UndoItem>) (ti => ti.isCommitted = true));
       }
       this.TransactionList.Add(item);
       return this.isCommitted;
 }
Beispiel #3
0
 public void Push(UndoItem item, bool resetRedoStack)
 {
     if (this.Suspend)
     return;
       if (item.State == UndoItem.TransactionState.Begin)
     this.transactionItem = item;
       else if (item.State != UndoItem.TransactionState.None && this.transactionItem.AddTransactionItem(item))
       {
     item = this.transactionItem;
     this.transactionItem = (UndoItem) null;
       }
       if (this.undoItems.Count == this.maxDepth)
     this.undoItems.RemoveAt(0);
       this.undoItems.Add(item);
       if (resetRedoStack)
     this.redoItems.Clear();
       this.UndoRedoAvailableChanged();
 }
Beispiel #4
0
 public void Push(UndoItem item)
 {
     this.Push(item, false);
 }