Beispiel #1
0
        /// <summary>
        /// Performs a redo
        /// </summary>
        /// <returns>False if there weren't any redos, true otherwise</returns>
        public bool Redo()
        {
            if (!this.AnyRedos)
            {
                return(false);
            }

            bool anyUndosChange = m_undoStack.Count == 0;
            bool anyRedosChange = m_redoStack.Count == 1;

            IUndoableAction action = m_redoStack[0];

            m_redoStack.RemoveAt(0);

            action.Do();
            m_undoStack.Insert(0, action);


            if (anyUndosChange)
            {
                this.RaisePropertiesChanged(nameof(AnyUndos));
            }
            else if (anyRedosChange)
            {
                this.RaisePropertiesChanged(nameof(AnyRedos));
            }

            return(true);
        }
Beispiel #2
0
        public IAction Redo()
        {
            if (redoStack.Count > 0)
            {
                IUndoableAction action = null;
                while (redoStack.Count > 0)
                {
                    action = redoStack.Pop();
                    Logger.Log(LOGKEY, "redo action: " + action.ToString());

                    if (BeforePerformAction != null)
                    {
                        var arg = new ActionEventArgs(action, ActionBehavior.Redo);
                        BeforePerformAction(this, arg);
                        if (arg.Cancel)
                        {
                            break;
                        }
                    }

                    action.Do();
                    undoStack.Add(action);
                    if (AfterPerformAction != null)
                    {
                        AfterPerformAction(this, new ActionEventArgs(action, ActionBehavior.Redo));
                    }

                    if (!(action is ISerialUndoAction))
                    {
                        break;
                    }
                }
                return(action);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Executes an action (calls <see cref="IUndoableAction.Do"/>) and then adds it to the stack for management
 /// </summary>
 public void ExecuteAction(IUndoableAction action)
 {
     action.Do();
     this.AddAction(action);
 }