Ejemplo n.º 1
0
        public void ExecuteCommand(Command cmd)
        {
            if (disabledCommands > 0)
            {
                return;
            }

            if (cmd is UndoableCommand)
            {
                (cmd as UndoableCommand).autoUndo = autoUndoCommands > 0;
                history.Push(cmd as UndoableCommand);
            }
            try
            {
                cmd.Execute();
            }
            catch (ArgumentOutOfRangeException)
            {
                //OnTextChanging cancels enter of the text
                if (cmd is UndoableCommand)
                {
                    history.Pop();
                }
            }
            //
            redoStack.Clear();
            //
            TextSource.CurrentTB.OnUndoRedoStateChanged();
        }
Ejemplo n.º 2
0
        public virtual void ExecuteCommand(Command cmd)
        {
            if (disabledCommands > 0)
            {
                return;
            }

            //multirange ?
            if (cmd.ts.CurrentTB.Selection.ColumnSelectionMode)
            {
                if (cmd is UndoableCommand)
                {
                    //make wrapper
                    cmd = new MultiRangeCommand((UndoableCommand)cmd);
                }
            }


            if (cmd is UndoableCommand)
            {
                //if range is ColumnRange, then create wrapper
                (cmd as UndoableCommand).autoUndo = autoUndoCommands > 0;
                history.Push(cmd as UndoableCommand);
            }

            try
            {
                cmd.Execute();
            }
            catch (ArgumentOutOfRangeException)
            {
                //OnTextChanging cancels enter of the text
                if (cmd is UndoableCommand)
                {
                    history.Pop();
                }
            }

            //
            if (!UndoRedoStackIsEnabled)
            {
                ClearHistory();
            }
            //
            redoStack.Clear();
            //
            TextSource.CurrentTB.OnUndoRedoStateChanged();
        }
Ejemplo n.º 3
0
        public void Undo()
        {
            if (history.Count > 0)
            {
                var cmd = history.Pop();
                //
                BeginDisableCommands();//prevent text changing into handlers
                try
                {
                    cmd.Undo();
                }
                finally
                {
                    EndDisableCommands();
                }
                //
                redoStack.Push(cmd);
            }

            //undo next autoUndo command
            if (history.Count > 0)
            {
                if (history.Peek().autoUndo)
                {
                    Undo();
                }
            }
        }
Ejemplo n.º 4
0
        public void ExecuteCommand(Command cmd)
        {
            if (disabledCommands <= 0)
            {
                var undo = cmd as UndoableCommand;

                //multirange ?
                if (cmd.ts.CurrentTB.Selection.ColumnSelectionMode && undo != null)
                {
                    //make wrapper
                    cmd = new MultiRangeCommand(undo);
                }


                if (undo != null)
                {
                    //if range is ColumnRange, then create wrapper
                    undo.autoUndo = autoUndoCommands > 0;
                    _history.Push(undo);
                }

                try
                {
                    cmd.Execute();
                }
                catch (ArgumentOutOfRangeException)
                {
                    if (undo != null)
                    {
                        _history.Pop();
                    }
                }

                _redoStack.Clear();
                TextSource.CurrentTB.OnUndoRedoStateChanged();
            }
        }