Exemplo n.º 1
0
        public void Undo()
        {
            IAction lastAction = Actions.Pop();
            IAction redoAction = lastAction.GetInverseAction();

            RedoActions.Push(redoAction);
            lastAction?.Revert();
        }
Exemplo n.º 2
0
        public void Redo()
        {
            IAction lastUndoAction = RedoActions.Pop();
            IAction undoAction     = lastUndoAction.GetInverseAction();

            Actions.Push(undoAction);
            lastUndoAction?.Revert();
        }
Exemplo n.º 3
0
        public void Redo(IAction action)
        {
            var index = Actions.IndexOf(action);

            if (index != -1)
            {
                for (var i = 0; i <= index; i++)
                {
                    IAction undoAction = Actions.Pop();
                    var     redoAction = undoAction.GetInverseAction();
                    RedoActions.Push(redoAction);
                    undoAction.Revert();
                }
            }
        }
Exemplo n.º 4
0
        public void Redo(UndoRedoAction a_action = null)
        {
            if (!CanRedo)
            {
                throw new InvalidOperationException();
            }
            if (IsInUndoRedo)
            {
                throw new InvalidOperationException();
            }

            if (a_action == null)
            {
                a_action = RedoActions.First();
            }
            if (!RedoActions.Contains(a_action))
            {
                throw new ArgumentException();
            }

            m_undo_redo = true;

            try
            {
                var todo = RedoActions.Reverse().SkipWhile(a => a != a_action).Reverse();

                todo.First().UndoState.Save();

                foreach (var action in todo)
                {
                    if (UndoRedoConfiguration.Logging)
                    {
                        System.Console.WriteLine("redo: " + action.RedoDescription);
                    }

                    action.Redo();
                    m_action_index++;
                }

                todo.Last().RedoState.Restore();
            }
            finally
            {
                m_undo_redo = false;
            }

            OnChanged();
        }
Exemplo n.º 5
0
 private void AddUndoAction(IAction action)
 {
     Actions.Push(action);
     RedoActions.Clear();
 }