Exemplo n.º 1
0
        /// <summary>Adds the specified action to be listed as an action that can be undone</summary>
        public static void AddAction(UndoableAction action)
        {
            if (redoStack.Count > 0)
            {
                redoStack.Clear();
            }

            activitiesStack.Push(action);

            //todo apply ( remove excess code )
            action.Apply();

            OnUndoAltered(activitiesStack.Count, action);
            OnRedoAltered(redoStack.Count, null);
        }
Exemplo n.º 2
0
        /// <summary>Undoes the last action performed, if any</summary>
        public static void Undo()
        {
            if (!CanUndo)
            {
                return;
            }
            UndoableAction action = activitiesStack.Pop();

            action.Undo();
            redoStack.Push(action);

            OnRedoAltered(redoStack.Count, action);
            if (activitiesStack.Count == 0)
            {
                OnUndoAltered(activitiesStack.Count, null);
            }
            else
            {
                OnUndoAltered(activitiesStack.Count, activitiesStack.Peek());
            }
        }