예제 #1
0
        /// <summary>
        /// Redo the last action.
        /// </summary>
        public void Redo()
        {
            if (_redoList.Count == 0)
            {
                return;
            }

            // Get the latest action to redo
            UndoableAction action = _redoList[_redoList.Count - 1];

            // Redo that action
            action.Do(true);

            // Remove the action from the redo list and add it to the undo list
            _redoList.Remove(action);
            _undoList.Add(action);

            // Add action record to the history log
            ActionRecord ar = new ActionRecord(DateTime.Now, action.Name,
                                               action.Description, ActionType.Redo);

            _actionsHistory.Add(ar);

            // Notify that the state of the undo manager has changed
            if (UndoStateChanged != null)
            {
                UndoStateChanged(this, EventArgs.Empty);
            }
        }
예제 #2
0
        /// <summary>
        /// Do the specified action while updating the internal undo/redo lists.
        /// </summary>
        /// <param name="action">The action to perform</param>
        public void Do(UndoableAction action)
        {
            // Do the action
            action.Do(false);

            // Clear the redo list
            _redoList.Clear();

            // Add the action to the undo list.
            _undoList.Add(action);

            // Add action record to the history log
            ActionRecord ar = new ActionRecord(DateTime.Now, action.Name,
                                               action.Description, ActionType.Do);

            _actionsHistory.Add(ar);

            // Notify that the state of the undo manager has changed
            if (UndoStateChanged != null)
            {
                UndoStateChanged(this, EventArgs.Empty);
            }
        }