Esempio n. 1
0
        public void Push(UndoAction action)
        {
            // Remove any "redo" actions from the history.
            //   +---+   +---+   +---+   +---+   +---+
            //   | 0 | > | 1 | > | 2 | > | 3 | > | 4 |
            //   +---+   +---+   +---+   +---+   +---+
            //                     ^current
            //   count = 5; current = 2;
            //   Remove the last 2 items.
            int nCount = m_history.Count;

            if (nCount > m_nCurrent + 1)
            {
                m_history.RemoveRange(m_nCurrent + 1, nCount - (m_nCurrent + 1));
                if (m_owner != null)
                {
                    m_owner.RemoveUndoRange(m_id, m_nCurrent + 1, nCount - (m_nCurrent + 1));
                }
            }

            // Add the new item at the end.
            //   +---+   +---+   +---+   +---+
            //   | 0 | > | 1 | > | 2 | > | N |
            //   +---+   +---+   +---+   +---+
            //                     ^old    ^current
            m_history.Add(action);
            m_nCurrent++;
            if (m_owner != null)
            {
                m_owner.AddUndo(m_id, action);
                m_owner.SetCurrentUndo(m_id, m_nCurrent);
            }

            // Remove the oldest action if the stack is too large.
            //   +---+   +---+   +---+
            //   | 1 | > | 2 | > | N |
            //   +---+   +---+   +---+
            //                     ^current
            if (m_history.Count > k_nMaxUndoHistory)
            {
                m_history.RemoveAt(0);
                m_nCurrent--;
                if (m_owner != null)
                {
                    m_owner.RemoveUndo(m_id, 0);
                    m_owner.SetCurrentUndo(m_id, m_nCurrent);
                }
            }
        }
Esempio n. 2
0
        public void Add(TabMgr.TabId id, UndoAction action)
        {
            ListBox lb = GetListbox(id);

            lb.Items.Add(action.Description);
        }
Esempio n. 3
0
 public void AddUndo(TabMgr.TabId id, UndoAction action)
 {
     m_undoHistory.Add(id, action);
 }