public void AddAndExecute(IUndoRedoCommand command)
 {
     _undoStack.Push(command);
     _redoStack.Clear();
     command.Execute();
     UpdateCommandStatus();
 }
示例#2
0
        /// <inheritdoc/>
        public void AddAndExecute(IUndoRedoCommand command, bool ignoreRedundant = true)
        {
            if (ignoreRedundant && command.IsRedundant)
            {
                return;
            }

            if (this.commands.Count == 0)
            {
                this.commands.Add(command);
                this.commandIndex = 0;
            }
            else
            {
                if (this.direction == Direction.Reverse)
                {
                    this.commands[this.commandIndex] = command;
                    this.RemoveCommandsAfterCurrentIndex();
                }
                else
                {
                    this.RemoveCommandsAfterCurrentIndex();
                    this.commands.Add(command);
                    this.commandIndex = this.commands.Count - 1;
                }
            }

            command.Execute();
            this.direction = Direction.Forward;
        }
        public void Redo()
        {
            IUndoRedoCommand command = _redoStack.Pop();

            _undoStack.Push(command);
            command.Execute();
            UpdateCommandStatus();
        }
        /// <summary>
        /// Redoes an action
        /// </summary>
        public void Redo()
        {
            IUndoRedoCommand cmd = RedoList.Last();

            cmd.Execute();
            RedoList.Remove(cmd);
            UndoList.Add(cmd);
        }
 public void Redo()
 {
     if (redoStack.Any())
     {
         IUndoRedoCommand command = redoStack.Pop();
         undoStack.Push(command);
         command.Execute();
     }
 }
示例#6
0
 public void InsertInUndoRedo(IUndoRedoCommand command)
 {
     _undoCommands.Push(command);
     _redoCommands.Clear();
     command.Execute();
     EnableUndo = CanUndo(1);
     RaisePropertyChanged(nameof(EnableUndo));
     RaisePropertyChanged(nameof(EnableRedo));
 }
示例#7
0
 /// <summary>
 /// Executes the action and pushes it to the appropriate stack
 /// </summary>
 public void Execute(IUndoRedoCommand command)
 {
     lock (_lockObject)
     {
         _executeInProgress = true;
         command.Execute();
         Push(command);
         _executeInProgress = false;
     }
 }
示例#8
0
 // Bruges til at tilføje commander.
 public void AddAndExecute(IUndoRedoCommand command)
 {
     undoStack.AddFirst(command);
     if (undoStack.Count == 50)
     {
         undoStack.RemoveLast();
     }
     redoStack.Clear();
     command.Execute();
 }
示例#9
0
 public void AddAndExecute(IUndoRedoCommand command)
 {
     _undoStack.Push(command);
     _redoStack.Clear();
     command.Execute();
     UpdateCommandStatus();
     foreach (var v in _undoStack)
     {
         Console.WriteLine(v.ToString());
     }
 }
示例#10
0
 public void Apply(IUndoRedoCommand command)
 {
     if (IsChangeTracking)
     {
         transaction.Add(command);
     }
     else
     {
         command.Execute();
     }
 }
示例#11
0
        // Udfører redo hvis det kan lade sig gøre.
        public void Redo()
        {
            if (redoStack.Count() <= 0)
            {
                throw new InvalidOperationException();
            }
            IUndoRedoCommand command = redoStack.Pop();

            undoStack.Push(command);
            command.Execute();
        }
示例#12
0
 // Bruges til at tilføje commander.
 public void AddAndExecute(IUndoRedoCommand command)
 {
     if (undoList.Count > 10)
     {
         undoList.RemoveLast();
     }
     undoList.AddFirst(command);
     redoList.Clear();
     //Trace.Write("Command was pushed to undostack: " + command.ToString() + "\n");
     undoStack.Push(command);
     redoStack.Clear();
     command.Execute();
 }
示例#13
0
        /// <summary>
        /// Выполняет новую команду
        /// </summary>
        /// <param name="command">команда</param>
        public void ExecuteNewCommand(IUndoRedoCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            if (UndoedCommands.Any())
            {
                UndoedCommands.Clear();
            }

            Commands.Add(command);
            command.Execute();
        }
示例#14
0
        // Udfører redo hvis det kan lade sig gøre.
        public void Redo()
        {
            if (redoStack.Count() <= 0)
            {
                throw new InvalidOperationException();
            }
            IUndoRedoCommand command = redoStack.First();

            undoStack.AddFirst(command);
            command.Execute();

            if (redoStack.Any())
            {
                redoStack.RemoveFirst();
            }
        }
 // Used for adding the Undo/Redo command to the 'undoStack' and at the same time executing it.
 public void AddAndExecute(IUndoRedoCommand command)
 {
     undoStack.Push(command);
     redoStack.Clear();
     command.Execute();
 }
 public void AddAndExecute(IUndoRedoCommand command)
 {
     undoStack.Push(command);
     redoStack.Clear();
     command.Execute();
 }
示例#17
0
 public void InsertInUndoRedo(IUndoRedoCommand command)
 {
     _undoCommands.Push(command);
     _redoCommands.Clear();
     command.Execute();
     EnableUndo = CanUndo(1);
     RaisePropertyChanged(nameof(EnableUndo));
     RaisePropertyChanged(nameof(EnableRedo));
     Messenger.Default.Send(new UndoRedoEnabledMsg(true,false));
 }