Example #1
0
        /// <summary>
        ///
        /// </summary>
        public void Redo()
        {
            if (CanRedo)
            {
                m_IsProcessing = true;

                try
                {
                    IUndoCommand command = m_Redo.Pop();

                    LogManager.Instance.WriteLine(LogVerbosity.Trace, "UndoRedo Redo({0}) : history list: {1} item(s)",
                                                  command.ToString(), m_Undo.Count);

                    command.Redo();
                    m_Undo.Push(command);

                    OnPropertyChanged("CanUndo");
                    OnPropertyChanged("CanRedo");

                    if (UndoRedoCommandExecuted != null)
                    {
                        UndoRedoCommandExecuted(null, EventArgs.Empty);
                    }
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    m_IsProcessing = false;
                }
            }
        }
Example #2
0
        /// <summary>Function to perform a redo operation.</summary>
        /// <returns>A task representing the currently executing redo operation.</returns>
        public Task Redo()
        {
            if ((_undoStack.Count == 0) || (_undoIndex >= _undoStack.Count - 1))
            {
                _undoIndex = _undoStack.Count - 1;
                return(Task.FromResult <object>(null));
            }

            try
            {
                IUndoCommand redo = _undoStack[++_undoIndex];

                if (redo == null)
                {
                    return(Task.FromResult <object>(null));
                }

                _cancelSource = new CancellationTokenSource();
                _log.Print($"Executing redo for '{redo.Description}' command.", LoggingLevel.Simple);
                Task task = redo.Redo(_cancelSource.Token);

                if (_cancelSource.Token.IsCancellationRequested)
                {
                    --_undoIndex;
                }

                return(task);
            }
            finally
            {
                _cancelSource?.Dispose();
                _cancelSource = null;
            }
        }
        public void RedoCommand()
        {
            if (redoStack.Count == 0)
            {
                return;
            }
            IUndoCommand cmd = redoStack.Pop();

            try
            {
                cmd.Redo();
                //if (!CanRedo()) (Env.Current.MainWindow as MainForm).redoButton.Enabled = false;
                documentModifiedState = view.IsModified;
                view.IsModified       = true;
            }
            finally
            {
                undoStack.Push(cmd);
                RaiseCanExecuteChanged();
                //(Env.Current.MainWindow as MainForm).undoButton.Enabled = true;
            }
        }