/// <summary> /// Performs an undo /// </summary> /// <returns>False if there weren't any undos, true otherwise</returns> public bool Undo() { if (!this.AnyUndos) { return(false); } bool anyUndosChange = m_undoStack.Count == 1; bool anyRedosChange = m_redoStack.Count == 0; IUndoableAction action = m_undoStack[0]; m_undoStack.RemoveAt(0); action.Undo(); m_redoStack.Insert(0, action); if (anyUndosChange) { this.RaisePropertiesChanged(nameof(AnyUndos)); } else if (anyRedosChange) { this.RaisePropertiesChanged(nameof(AnyRedos)); } return(true); }
public void Undo() { if (UndoList.Count > 0) { IUndoableAction act = UndoList.Pop(); act.Undo(this); OnUndoChanged(UndoChangedEventArgs.Empty); RedoList.Push(act); OnRedoChanged(RedoChangedEventArgs.Empty); } }
public IAction Undo() { if (undoStack.Count() > 0) { IUndoableAction action = null; while (undoStack.Count > 0) { action = undoStack.Last(); Logger.Log(LOGKEY, "undo action: " + action.ToString()); // before event if (BeforePerformAction != null) { var arg = new ActionEventArgs(action, ActionBehavior.Undo); BeforePerformAction(this, new ActionEventArgs(action, ActionBehavior.Undo)); if (arg.Cancel) { break; } } undoStack.Remove(action); action.Undo(); redoStack.Push(action); // after event AfterPerformAction?.Invoke(this, new ActionEventArgs(action, ActionBehavior.Undo)); if (!(action is ISerialUndoAction)) { break; } } return(action); } return(null); }