Пример #1
0
    void processCommand(IGIICommand cmd)
    {
        // 立即执行,并且结束 !!(所以对于 MacroCommand,如果有一个操作需要等待,则整个操作都不立即执行)
        cmd.ExecuteInCommandCenter(this);

        if (!cmd.IsFinished())
        {
            _pendingCommands.Push(cmd);
        }

        // 处理由该Command产生的消息
        sendPendingEvents(_inProcessingCommands + 1);
    }
Пример #2
0
    public virtual bool ExecuteInCommandCenter(IGIICommandCenter commandCenter)
    {
        if (_currentCommand == null)
        {
            // 出现这种情况的时候表示当前指令已经执行完
//			Debug.Assert(false, "!! Current Command is finished already !!");
            return(true);
        }

        _currentCommand.ExecuteInCommandCenter(commandCenter);
        while (_currentCommand.IsFinished() && _subCommands.Count > 0)
        {
            _currentCommand = _subCommands.Dequeue();
            _currentCommand.ExecuteInCommandCenter(commandCenter);
        }

        if (_currentCommand.IsFinished())
        {
            _currentCommand = null;
            return(true);
        }

        return(_currentCommand.IsFinished());         // always false
    }