示例#1
0
        /// <summary>
        /// Redo the number of actions specified by <paramref name="count"/>.
        /// </summary>
        /// <param name="count">The number of actions to redo.</param>
        public void Redo(int count = 1)
        {
            lock (LockObject)
            {
                if (count > RedoActions.Count)
                {
                    throw new ArgumentOutOfRangeException("Can't redo the number of actions specified.", nameof(count));
                }

                IsRedoing = true;
                for (var i = 0; i < count; i++)
                {
                    // Get the next action to redo.
                    var action = RedoActions.Peek();
                    OnBeforeRedo(new UndoEventArgs(action));
                    action.Redo();

                    // Add the action to the undo stack.
                    UndoActions.Push(RedoActions.Pop());
                    OnAfterRedo(new UndoEventArgs(action));
                }
                IsRedoing = false;
                OnChanged(EventArgs.Empty);
            }
        }
示例#2
0
 /// <summary>
 /// Adds a new action to the undo stack and clears the redo stack.
 /// </summary>
 /// <param name="action"></param>
 public void Add(IUndoAction action)
 {
     lock (LockObject)
     {
         UndoActions.Push(action);
         RedoActions.Clear();
     }
     OnChanged(EventArgs.Empty);
 }
示例#3
0
        public TextAction Add(TextCursor cursor, TextAction.ActionType type)
        {
            TextAction action = new TextAction(cursor, type);

            UndoActions.Push(action);
            if (RedoActions.Any())
            {
                RedoActions.Clear();
            }
            return(action);
        }
示例#4
0
        public bool Redo(out TextCursor cursor)
        {
            cursor = null;
            if (!RedoActions.Any())
            {
                return(false);
            }
            var action = RedoActions.Pop();

            cursor = action.Cursor;
            cursor.Redo(action);
            UndoActions.Push(action);
            return(RedoActions.Any());
        }