예제 #1
0
        public void Redo(int n = 1)
        {
            if ((n < 1) || (n > NumRedoable))
            {
                throw new ArgumentOutOfRangeException("n");
            }

            bool undo_changed = false;

            for (int i = 0; i < n; i++)
            {
                UndoAction item = m_redoable.Pop();
                item.Redo();

                // Initially planned on not putting it back on the undo stack, and instead expecting
                // it to eventually be re-added by the client (through events, etc).  However, since
                // deciding that element events will *not* be forwarded up through the control, it
                // might make sense to just re-add the undo action.
                _pushOntoUndoStack(item);
                undo_changed = true;
            }

            if (undo_changed)
            {
                OnUndoItemsChanged();
            }
            OnRedoItemsChanged();
        }
예제 #2
0
        private UndoAction _popFromUndoStack()
        {
            // Pop the item from the top of the stack.
            UndoAction action = m_undoable.First.Value;

            m_undoable.RemoveFirst();
            return(action);
        }
예제 #3
0
        private void _pushOntoUndoStack(UndoAction action)
        {
            // Push the item onto the top of the stack.
            m_undoable.AddFirst(action);

            if (m_undoable.Count > MaxItems)
            {
                // Remove one item from the bottom of the stack.
                m_undoable.RemoveLast();
            }
        }
예제 #4
0
        public void Undo(int n = 1)
        {
            if ((n < 1) || (n > NumUndoable))
            {
                throw new ArgumentOutOfRangeException("n");
            }

            for (int i = 0; i < n; i++)
            {
                UndoAction item = _popFromUndoStack();
                item.Undo();
                m_redoable.Push(item);
            }
            OnUndoItemsChanged();
            OnRedoItemsChanged();
        }
예제 #5
0
 public void AddUndoAction(UndoAction action)
 {
     _pushOntoUndoStack(action);
     OnUndoItemsChanged();
 }
예제 #6
0
 public void AddUndoAction(UndoAction action)
 {
     _pushOntoUndoStack(action);
     OnUndoItemsChanged();
 }
예제 #7
0
        private void _pushOntoUndoStack(UndoAction action)
        {
            // Push the item onto the top of the stack.
            m_undoable.AddFirst(action);

            if (m_undoable.Count > MaxItems) {
                // Remove one item from the bottom of the stack.
                m_undoable.RemoveLast();
            }
        }