Example #1
0
        /// <summary>
        /// Add a undo/redo command to the stack and pop all trailing commands after the current command
        /// </summary>
        /// <param name="item"></param>
        public void PushHistoryItem(UndoRedoCommand item)
        {
            while (this.HistoryStackTop > CurrentIndex)
            {
                PopHistoryItem();
            }

            _historyStack.Add(item);
            CurrentIndex = this.HistoryStackTop;

            if (ItemPushed != null)
            {
                ItemPushed(this, EventArgs.Empty);
            }
        }
Example #2
0
 /// <summary>
 /// Perform redo on next command
 /// </summary>
 public void Redo()
 {
     if (this.CanRedo)
     {
         try
         {
             _isUndoingOrRedoing = true;
             ++CurrentIndex;
             UndoRedoCommand currentItem = _historyStack[CurrentIndex];
             currentItem.ObjectType.GetProperty(currentItem.AffectedPropertyName).SetValue(currentItem.Object, currentItem.NewValue, null);
         }
         finally
         {
             _isUndoingOrRedoing = false;
         }
     }
 }