public ProjectCommandWrapper(
			ProjectCommandAdapter adapter,
			IUndoableCommand<BlockCommandContext> command)
        {
            Adapter = adapter;
            this.command = command;
        }
Exemplo n.º 2
0
 public ProjectCommandWrapper(
     ProjectCommandAdapter adapter,
     IUndoableCommand <BlockCommandContext> command)
 {
     Adapter      = adapter;
     this.command = command;
 }
Exemplo n.º 3
0
        public void Execute(IUndoableCommand command)
        {
            command.Execute();
            _undoStack.Push(command);
            _redoStack.Clear();

            OnCommandExecuted();
        }
Exemplo n.º 4
0
 public void Undo()
 {
     if (_history.Count != 0)
     {
         IUndoableCommand command = _history.Pop();
         command.Undo();
     }
 }
        public async Task ExecuteAsync(IUndoableCommand command)
        {
            await command.ExecuteAsync();

            _undoStack.Push(command);

            OnCommandExecuted();
        }
Exemplo n.º 6
0
 public void InsertCommand(int index, IUndoableCommand cmd)
 {
     if (cmd == null)
     {
         return;
     }
     _cmdList.Insert(index, cmd);
 }
Exemplo n.º 7
0
 public void Push(IUndoableCommand command)
 {
     if (_commands.Count >= _maxDepth)
     {
         _commands.RemoveLast();
     }
     _commands.AddFirst(command);
 }
Exemplo n.º 8
0
 public void AddCommand(IUndoableCommand cmd)
 {
     if (cmd == null)
     {
         return;
     }
     _cmdList.Add(cmd);
 }
Exemplo n.º 9
0
 public void Undo()
 {
     if ((commands.Count > 0) && (commands.Peek() is IUndoableCommand))
     {
         IUndoableCommand command = (IUndoableCommand)commands.Pop();
         command.Undo();
     }
 }
Exemplo n.º 10
0
 public void Redo()
 {
     if (this.redoStack.Count > 0)
     {
         IUndoableCommand command = this.redoStack.Pop();
         this.undoStack.Push(command);
         command.Redo();
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Undo this instance.
 /// </summary>
 public void undo()
 {
     if (_iUndoableCommands.Count > 0)
     {
         IUndoableCommand toBeRemoved_iundoablecommand = _iUndoableCommands[_iUndoableCommands.Count - 1];
         toBeRemoved_iundoablecommand.undo();
         _iUndoableCommands.RemoveAt(_iUndoableCommands.Count - 1);
     }
 }
Exemplo n.º 12
0
 public IUndoableCommand Pop()
 {
     if (_commands.First != null)
     {
         IUndoableCommand first = _commands.First.Value;
         _commands.RemoveFirst();
         return(first);
     }
     return(EmptyCommand.GetEmptyCommand());
 }
Exemplo n.º 13
0
        public void ExecuteCommand(IUndoableCommand cmd)
        {
            if (cmd == null)
            {
                return;
            }

            cmd.Execute();
            _undoStack.Push(cmd);
        }
Exemplo n.º 14
0
 private void InvokeLDNetworksChangedEvent(IUndoableCommand command)
 {
     if (command is LadderDiagramReplaceNetworksCommand ||
         command is LadderDiagramRemoveNetworksCommand ||
         command is LadderDiagramExchangeNetworkCommand ||
         command is LadderDiagramMoveNetworkCommand)
     {
         ldvmodel.InvokeLDNetworksChanged();
     }
 }
Exemplo n.º 15
0
 public bool AssertEdit(IUndoableCommand command)
 {
     if (ldvmodel != null &&
         ldvmodel.LadderMode != LadderMode.Edit &&
         !(command is NetworkReplaceBreakpointCommand))
     {
         LocalizedMessageBox.Show(Properties.Resources.Change_Mode, LocalizedMessageIcon.Warning);
         return(false);
     }
     return(true);
 }
Exemplo n.º 16
0
        public void RedoLatest()
        {
            if (_redoStack.Count == 0)
            {
                return;
            }

            IUndoableCommand cmd = _redoStack.Pop();

            cmd.Redo();
            _undoStack.Push(cmd);
        }
Exemplo n.º 17
0
        private void InitializeSlots()
        {
            var noCommand = NO_COMMAND;

            for (int i = 0; i < _numberOfSlots; i++)
            {
                _onCommands.Add(noCommand);
                _offCommands.Add(noCommand);
            }

            undoCommand = NO_COMMAND;
        }
Exemplo n.º 18
0
        protected override void Undo(
            IUndoableCommand <BlockCommandContext> command,
            BlockCommandContext context)
        {
            // Handle the base operation.
            base.Undo(command, context);

            // Handle the post operation for the wrapped command.
            var wrappedCommand = (IWrappedCommand)command;

            wrappedCommand.PostUndo(operationContext);
        }
Exemplo n.º 19
0
        public bool ExecuteCommand(IUndoableCommand command)
        {
            // Any execution removes all previous undoCommands for redo functionality.
            if (undoneCommands.Any())
            {
                undoneCommands.Clear();
            }

            commands.Push(command);

            return(command.Execute());
        }
        /// <summary>
        /// Internal method for executing a command with a specific context.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="context">The context of the execution.</param>
        protected virtual void Do(
            IUndoableCommand <TContext> command,
            TContext context)
        {
            // Establish our contracts.
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // Execute the command and get its state.
            command.Do(context);
        }
Exemplo n.º 21
0
 public void Execute(IUndoableCommand command)
 {
     if (!AssertEdit(command))
     {
         return;
     }
     command.Execute();
     InvokeLDNetworksChangedEvent(command);
     IsModify = true;
     if (command is ElementReplaceArgumentCommand &&
         !((ElementReplaceArgumentCommand)command).CanUndo)
     {
         return;
     }
     UndoStack.Push(command);
     RedoStack.Clear();
 }
Exemplo n.º 22
0
        protected override void Do(
            object context,
            CommandFactoryManager <OperationContext> commandFactory,
            object commandData,
            OperationContext operationContext,
            EditorViewController controller,
            IDisplayContext displayContext,
            TextPosition position)
        {
            // If we don't have a selection, this is a simple insert command.
            TextPosition bufferPosition = displayContext.Caret.Position;
            TextRange    selection      = displayContext.Caret.Selection;

            if (!selection.IsEmpty)
            {
                // Create and execute the delete command. We do this separately
                // so they show up as a different undo item.
                IUndoableCommand <OperationContext> deleteCommand =
                    DeleteSelectionCommandFactory.CreateCommand(controller, displayContext);

                controller.CommandController.Do(deleteCommand, operationContext);

                // We have to reset the position so the insert happens as if
                // the text doesn't exist.
                bufferPosition   = selection.FirstTextPosition;
                operationContext = new OperationContext(
                    operationContext.LineBuffer, bufferPosition);
            }

            // Create the insert command using the (potentially) modified selection.
            string text = commandData.ToString();
            IInsertTextCommand <OperationContext> insertCommand =
                controller.CommandController.CreateInsertTextCommand(bufferPosition, text);

            insertCommand.UpdateTextPosition = DoTypes.All;

            controller.CommandController.Do(insertCommand, operationContext);

            // If we have a text position, we need to set it.
            if (operationContext.Results.HasValue)
            {
                displayContext.Caret.SetAndScrollToPosition(
                    operationContext.Results.Value.TextPosition);
            }
        }
Exemplo n.º 23
0
        public void LaunchUndoableCommand(IUndoableCommand command)
        {
            if (command == null)
            {
                return;
            }

            if ((commandStack.Count - 1) > playHead)
            {
                commandStack.RemoveRange(playHead + 1, (commandStack.Count - 1) - playHead);
            }

            commandStack.Add(command);
            playHead = commandStack.Count - 1;
            isEmpty  = false;

            DoCurrentCommand();
            UpdateMenus();
        }
Exemplo n.º 24
0
        public void Undo()
        {
            if (!CanUndo)
            {
                return;
            }

            IUndoableCommand command = _undoStack[_undoStack.Count - 1];

            _undoStack.RemoveAt(_undoStack.Count - 1);

            if (command != null)
            {
                command.Undo();

                // Add to redo stack
                _redoStack.Add(command);
            }
        }
Exemplo n.º 25
0
        public void ExecuteCommand(IUndoableCommand command)
        {
            if (command == null)
            {
                return;
            }

            //if undo stack pointer is before the last index of the list, there have been undo actions made
            if (_undoStackPointer < _undoStack.Count)
            {
                //overwrite remaining undo stack
                _undoStack = _undoStack.GetRange(0, _undoStackPointer); //<-- undo stack becomes the first N actions, where N is the pointer value (convenient!)
            }

            command.Execute();
            Game.Log(Logging.Category.SONG_DATA, $"Editor command executed: {command.Description}.", Logging.Level.LOG);

            _undoStack.Add(command);
            _undoStackPointer++;
        }
Exemplo n.º 26
0
 public void Do(IUndoableCommand command, string commandName = "")
 {
     if (command != null)
     {
         if (RecordingSessionInProgress)
         {
             command.Do();
             transactionRecords.Peek().CommandsGroup.Commands.Add(command);
         }
         else
         {
             command.Do();
             redoCommands.Clear();
             undoCommands.Push(new CommandRecord {
                 Command = command, CommandName = commandName
             });
             OnPropertyChanged(nameof(UndoableCommands));
             OnPropertyChanged(nameof(RedoableCommands));
         }
     }
 }
        public void Undo(TContext context)
        {
            // Allow extending class to prepare for the operation.
            PreUndo(context);

            // To implement the command, simply iterate through the list
            // of commands and execute each one. The state comes from the last
            // command executed.
            IList <IUndoableCommand <TContext> > commands = Commands;

            for (int index = commands.Count - 1;
                 index >= 0;
                 index--)
            {
                IUndoableCommand <TContext> command = commands[index];
                Undo(command, context);
            }

            // Allow extending classes to complete the operation.
            PostUndo(context);
        }
Exemplo n.º 28
0
        public void BuildCompositeCommandAndPush(IUndoableCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException();
            }

            CompositeCommand commandToPush = command as CompositeCommand;

            if (commandToPush == null)
            {
                // If the push command is not CompositeCommand, then build a  CompositeCommand
                // to hold it as we should change to the page in which target widgets located first when undo/redo
                CompositeCommand cmds = new CompositeCommand();
                cmds.AddCommand(command);
                commandToPush = cmds;
            }


            ISelectionService selectionService = ServiceLocator.Current.GetInstance <SelectionServiceProvider>();

            if (selectionService != null && null != selectionService.GetCurrentPage())
            {
                // Add change page command in the first item.
                commandToPush.InsertCommand(0, new ChangePageCommand());
            }


            if (_undoStack.Count >= _undoLimit)
            {
                _undoStack.RemoveAt(0);
            }

            _undoStack.Add(commandToPush);

            Debug.WriteLine("Pushed a IUndoableCommand into undo stack. Undo stack count is : {0}.", _undoStack.Count);

            // New command is pushed in, clear the redo stack.
            _redoStack.Clear();
        }
Exemplo n.º 29
0
        public void LaunchUndoableCommand(IUndoableCommand command)
        {
            if (command != null)
            {
                // Dépiler ce qui est au dessus de la tête de lecture
                if ((m_CommandStack.Count - 1) > m_iPlayHead)
                {
                    m_CommandStack.RemoveRange(m_iPlayHead + 1, (m_CommandStack.Count - 1) - m_iPlayHead);
                }

                //Empiler la commande
                m_CommandStack.Add(command);
                m_iPlayHead = m_CommandStack.Count - 1;
                bIsEmpty    = false;

                //Executer la commande
                DoCurrentCommand();

                // Mise à jour du menu
                UpdateMenus();
            }
        }
    public bool Execute()
    {
        if (!IswaitToExecute)
        {
            return(false);
        }
        if (commandIndex >= commands.Count)
        {
            return(false);
        }

        IswaitToExecute = false;
        icommand        = commands[commandIndex];
        lastCommand     = icommand;
        if (icommand != null)
        {
            icommand.Execute();
            undoFunctions.Push(icommand.UnDo);
            commandIndex++;
        }
        return(true);
    }
Exemplo n.º 31
0
 private void PushUndo(IUndoableCommand command)
 {
     UndoableCommands.Add(command);
     NotifyPropertyChanged("LastUndoableCommand");
 }
Exemplo n.º 32
0
 /// <summary>
 /// Pushes a new command to the stack.
 /// </summary>
 /// <param name="command">The command to execute within this macro.</param>
 public void Push(IUndoableCommand command)
 {
     _commands.AddLast(command);
 }
Exemplo n.º 33
0
 /// <summary>
 /// Adds the command to macro.
 /// </summary>
 /// <param name="command">The command.</param>
 public void AddCommand(IUndoableCommand command)
 {
     Commands.Add(command);
 }
Exemplo n.º 34
0
 public void SaveCommand(IUndoableCommand command)
 {
     _history.Push(command);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Adds an open command to the OpenCommands list
 /// </summary>
 /// <param name="command">The command.</param>
 public void AddOpenCommand(IUndoableCommand command)
 {
     OpenCommands.Add(command);
 }
Exemplo n.º 36
0
 public void Log(IUndoableCommand command)
 {
     if (!replay)
     {
         PushUndo(command);
         RedoableCommands.Clear();
         HasUnsavedChanges = true;
     }
 }