Esempio n. 1
0
 public void FinishGroup(bool finish = true)
 {
     if (_undoStack.Count > 0)
     {
         _undoStack.Push(_undoStack.Pop().WithSeparatorFlag(finish));
         AfterAction.Fire(this, EventArgs.Empty);
     }
 }
Esempio n. 2
0
        /// <summary>Executes an action and adds it to the undo stack.</summary>
        /// <param name="action">Action to take. Initially called with an argument of true.</param>
        /// <param name="finishGroup">If you want to group multiple actions together
        /// so that one undo command undoes all of them, this parameter should be
        /// true only on the last action.</param>
        /// <remarks>If there are any actions on the tentative stack, they are accepted
        /// and grouped with this new action.</remarks>
        public virtual void Do(string name, DoOrUndo action, bool finishGroup = true)
        {
            Performing = ActionState.Do;

            if (action != null)
            {
                AcceptTentativeAction(false);
                _undoStack.Push(new Command(name, action, finishGroup).Do());
                _redoStack.Clear();
                AfterAction.Fire(this, EventArgs.Empty);
                // AfterAction(true);
            }
        }
Esempio n. 3
0
        public virtual bool Redo(bool run = true)
        {
            Performing = ActionState.Redo;
            if (_redoStack.Count == 0)
            {
                return(false);
            }
            if (run)
            {
                do
                {
                    _undoStack.Push(_redoStack.Pop().Redo());
                } while (!_undoStack.Peek().FinishGroup);

                AfterAction.Fire(this, EventArgs.Empty);
                // AfterAction(true);
            }
            return(true);
        }