public void Execute(uint tick, ICommand <T> cmd)
        {
#if DEBUG_SIMPLE_CHECK
            var iTick = (int)tick;
            for (int i = allCmds.Count; i <= iTick; i++)
            {
                allCmds.Add(null);
            }

            cmd.Do(_param);
            var node = new CommandNode(tick, cmd, _tail, null);
            allCmds[iTick] = node;
#else
            if (cmd == null)
            {
                return;
            }
            cmd.Do(_param);
            var node = new CommandNode(tick, cmd, _tail, null);
            if (_head == null)
            {
                _head = node;
                _tail = node;
                return;
            }

            _tail.next = node;
            _tail      = node;
#endif
        }
Example #2
0
        public void Add(ICommand command, bool execute = true)
        {
            if (inUndoRedo)
            {
                return;
            }
            if (lastExecuted + 1 < commands.Count)
            {
                int numCommandsToRemove = commands.Count - (lastExecuted + 1);
                for (int i = 0; i < numCommandsToRemove; i++)
                {
                    commands.RemoveAt(lastExecuted + 1);
                }
                lastSaved = -1;
            }
            commands.Add(command);
            lastExecuted = commands.Count - 1;

            if (execute)
            {
                command.Do(this);
            }

            OnChanged(true);
        }
Example #3
0
        //private static CommandsCollection instance;

        //public static CommandsCollection Default
        //{
        //	  get
        //	  {
        //		  if (instance == null)
        //			  instance = new CommandsCollection();
        //		  return instance;
        //	  }
        //}

        public void Do(ICommand command)
        {
            command.Do();

            undoStack.Push(command);
            redoStack.Clear();
        }
 public void Do(ICommand cmd)
 {
     cmd.Do();
     undoStack.Add(cmd);
     redoStack.Clear();
     OverflowCheck();
 }
Example #5
0
 public void ExeCommand(ICommand command)
 {
     if (command.Do())
     {
         Push(command);
     }
 }
Example #6
0
        /// <summary>
        /// 保存当前行记录
        /// </summary>
        /// <param name="ctx">当前数据项</param>
        public static void SaveContext(PanelContext ctx)
        {
            ctx.Row["ID"] = Utils.CreateGUID();
            ICommand command = CommandFactory.GetCommand("add");

            command.Do(ctx);
        }
Example #7
0
 /// <summary>
 /// Execute a command for XTMF
 /// </summary>
 /// <param name="command">The command to execute</param>
 /// <param name="error">In case of failure a description of the problem</param>
 /// <returns>If the command was successful or not.  If not error will contain a string describing why</returns>
 internal bool ProcessCommand(ICommand command, ref string error)
 {
     // ensure only 1 command at a time
     lock (this)
     {
         return(command.Do(ref error));
     }
 }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public T Do(ICommand <T> cmd, T input)
        {
            T output = cmd.Do(input);

            _Undo.Push(cmd);
            _Redo.Clear(); // Once we issue a new command, the redo stack clears
            return(output);
        }
Example #9
0
        public T Do(ICommand <T> action, T input)
        {
            T result = action.Do(input);

            sRedo.Clear();
            sUndo.Push(action);
            return(result);
        }
Example #10
0
        /// <summary>
        /// Выполнить команду
        /// </summary>
        /// <param name="cmd">Команда на выполнение</param>
        public void Do(ICommand cmd)
        {
            cmd.Do();

            UndoStack.Push(cmd);

            RedoStack.Clear();
        }
 public void Prepare(ICommand command)
 {
     if (preparing != null)
     {
         throw new Exception("有正在进行的命令,暂时不能准备新命令");
     }
     preparing = command;
     preparing.Do();
 }
Example #12
0
        public void Do(ICommand <T> command)
        {
            T temp = this.Target;

            command.Do(ref temp);
            this.Target = temp;

            this.AddToStack(command, this.undo);
        }
Example #13
0
        public void Execute(int tick, ICommand cmd)
        {
            for (int i = _allCMds.Count; i <= tick; i++)
            {
                _allCMds.Add(new List <ICommand>());
            }

            _allCMds[tick].Add(cmd);
            cmd.Do(_param);
        }
        public void Redo()
        {
            if (hasRedoCommand)
            {
                ICommand cmd = redoStack.Pop();

                cmd.Do();
                undoStack.Add(cmd);
            }
        }
Example #15
0
 private bool Undo(ICommand command)
 {
     if (!command.Do(Scene))
     {
         return(false);
     }
     _redoStack.Push(command);
     UpdateUI();
     return(true);
 }
Example #16
0
        public void Do(ICommand command)
        {
            if (RedoList.Count > 0)
            {
                RedoList.Clear();
            }

            command.Do();
            UndoList.Push(command);
        }
Example #17
0
    /// <summary>
    /// 操作を実行し、かつその内容を履歴に追加します。
    /// </summary>
    /// <param name="command">ICommandインターフェースを実装し、行う操作を定義したオブジェクト</param>
    public void Do(ICommand command)
    {
        this.undo.Push(command);
        this.CanUndo = this.undo.Count > 0;

        command.Do();

        this.redo.Clear();
        this.CanRedo = this.redo.Count > 0;
    }
Example #18
0
        /// <summary>
        /// 操作を実行し、かつその内容を履歴に追加します。
        /// </summary>
        /// <param name="command">ICommandインターフェースを実装し、行う操作を定義したオブジェクト</param>
        private void Do(ICommand command)
        {
            this._Undo.Push(command);
            this.CanUndo = this._Undo.Count > 0;

            command.Do();

            this.ClearRedoStack();
            this.CanRedo = this._Redo.Count > 0;
        }
Example #19
0
        public void Do(ICommand command)
        {
            if(RedoList.Count > 0)
            {
                RedoList.Clear();
            }

            command.Do();
            UndoList.Push(command);
        }
Example #20
0
        public void ExecuteCommand(ICommand command)
        {
            command.Do();
            _doneCommands.Push(command);

            if (_undoneCommands.Count > 0)
            {
                _undoneCommands.Clear();
            }
        }
Example #21
0
        void Redo()
        {
            if (redostack.Count == 0)
            {
                return;
            }
            ICommand cmd = redostack.Pop();

            undostack.Push(cmd);
            cmd.Do();
        }
Example #22
0
    public void Do()
    {
        if (RedoStack.Count == 0)
        {
            return;
        }
        ICommand currentundo = RedoStack.Pop();

        UndoStack.Push(currentundo);
        currentundo.Do();
    }
Example #23
0
        void AddCommand(ICommand command)
        {
            if (command == null)
            {
                return;
            }

            command.Do();
            undostack.Push(command);
            redostack.Clear();
        }
Example #24
0
        public void Redo(Type commandType)
        {
            ICommand <T> command = this.MoveFromStackToStack(commandType, this.redo, this.undo);

            if (command != null)
            {
                T temp = this.Target;
                command.Do(ref temp);
                this.Target = temp;
            }
        }
Example #25
0
        public void Redo()
        {
            if (hasRedoCommand)
            {
                ICommand cmd = redoStack[RedoCount - 1];

                cmd.Do();
                redoStack.Remove(cmd);
                undoStack.Add(cmd);
            }
        }
Example #26
0
        public static void Redo()
        {
            if (Redos.Count <= 0)
            {
                return;
            }
            ICommand command = Redos.Pop();

            command.Do();
            Undos.Push(command);
        }
Example #27
0
 public T Redo(T input)
 {
     if (sRedo.Count > 0)
     {
         ICommand <T> action = sRedo.Pop();
         T            result = action.Do(input);
         sUndo.Push(action);
         return(result);
     }
     return(input);
 }
Example #28
0
        private bool Redo(ICommand command, bool spoof = false)
        {
            var result = spoof || command.Do(Scene);

            if (result)
            {
                UndoStack.Push(command);
                UpdateUI();
            }
            return(result);
        }
Example #29
0
 void AutoEditor_OnInteralCommand(object sender, ModelEventArgs args)
 {
     if (!args.Disable)
     {
         ICommand cmd = CommandFactory.GetCommand(args.CommandName);
         if (cmd == null)
         {
             throw new SysException(cmd + "模型命令不存在");
         }
         args.State = cmd.Do(args.PanelContext);
     }
 }
Example #30
0
 protected virtual bool DoExecute(ICommand command)
 {
     try
     {
         command.Do();
         return(true);
     }
     catch (CommandExecutionCancelledException)
     {
         return(false);
     }
 }
Example #31
0
 public void Do(ICommand _command)
 {
     if (_command == null)
     {
         return;
     }
     this.undo.Push(_command);
     this.CanUndo = true;
     _command.Do();
     this.redo.Clear();
     this.CanRedo = false;
 }
Example #32
0
        public void Redo(TiledMapDataContainer container)
        {
            if (m_redoCommandStack.Count == 0)
            {
                throw new Exception("No commands to redo");
            }

            ICommand command = m_redoCommandStack.Pop();

            command.Do(container);
            m_undoCommandStack.Push(command);
        }
Example #33
0
 public void Do(ICommand command, TiledMapDataContainer container)
 {
     command.Do(container);
     m_undoCommandStack.Push(command);
     m_redoCommandStack.Clear();
 }
Example #34
0
        public void Add(ICommand command, bool execute = true)
        {
            if (lastExecuted + 1 < commands.Count)
            {
                int numCommandsToRemove = commands.Count
                          - (lastExecuted + 1);
                for (int i = 0; i < numCommandsToRemove; i++)
                {
                    commands.RemoveAt(lastExecuted + 1);
                }
                lastSaved = -1;
            }
            commands.Add(command);
            lastExecuted = commands.Count - 1; 

            if (execute)
            {
                command.Do(this);
            }

            OnChanged(true);
        }
Example #35
0
		void Redo(ICommand c)
		{
			c.Do(this);
			undoStack.Push(c);
			UndoCapabilityChanged();
		}
Example #36
0
        public void Do(ICommand command)
        {
            command.Do();
            undoStack.Push(command);

        }
Example #37
0
        public void Do(ICommand command)
        {
            if (CanUndo) {
                if (m_undoStack.Peek ().Chain (command))
                    return;
            }

            m_redoStack.Clear ();
            command.Do ();

            if (command.CanUndo)
                m_undoStack.Push (command);

            if (Changed != null)
                Changed (this, new EventArgs ());
        }
Example #38
0
 protected virtual bool DoExecute(ICommand command)
 {
     try
     {
         command.Do();
         return true;
     }
     catch (CommandExecutionCancelledException)
     {
         return false;
     }
 }