Пример #1
0
    public bool SubmitCommands(CommandList commands)
    {
        if (phase != GamePhase.COMMAND)
        {
            Debug.LogError("Commands sent on wrong phase!");
            return(false);
        }
        else
        {
            // add commands
            foreach (var command in commands)
            {
                if (allCommands.ContainsKey(command.Key))
                {
                    allCommands[command.Key] = command.Value;
                }
                else
                {
                    allCommands.Add(command.Key, command.Value);
                }
            }

            return(true);
        }
    }
Пример #2
0
        public vsCommandStatus QueryStatus(string commandName, WSPBuilderHandle WSPTool)
        {
            vsCommandStatus status = vsCommandStatus.vsCommandStatusNinched | vsCommandStatus.vsCommandStatusSupported;

            if (WSPTool.Running)
            {
                // The WSPTool is runnig no menu button available
                status |= vsCommandStatus.vsCommandStatusNinched;
            }
            else
            {
                if (CommandList.ContainsKey(commandName))
                {
                    CommandHandle handle = CommandList[commandName];

                    if (handle.StatusMethod != null)
                    {
                        status = handle.StatusMethod.Invoke();
                    }
                    else
                    {
                        bool found = true;

                        if (found)
                        {
                            status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
                        }
                    }
                }
            }

            return(status);
        }
Пример #3
0
        public Command CreateCommand(string name, string title, string description, string HotKey, ExecuteDelegate executeMethod, StatusDelegate statusMethod)
        {
            object[] contextGUIDS = new object[] { };
            Command  result       = null;

            string fullname = GetFullName(name);

            result = GetCommand(fullname);


            if (result == null)
            {
                Commands2 commands = (Commands2)ApplicationObject.Commands;
                result = commands.AddNamedCommand2(
                    AddInInstance,
                    name,
                    title,
                    description,
                    true,
                    0,
                    ref contextGUIDS,
                    (int)vsCommandStatus.vsCommandStatusSupported +
                    (int)vsCommandStatus.vsCommandStatusEnabled,
                    (int)vsCommandStyle.vsCommandStylePictAndText,
                    vsCommandControlType.vsCommandControlTypeButton);

                // *** If a hotkey was provided try to set it
                //result.Bindings = bindings;
                if (HotKey != null && HotKey != "")
                {
                    object[] bindings = (object[])result.Bindings;
                    if (bindings != null)
                    {
                        bindings    = new object[1];
                        bindings[0] = (object)HotKey;
                        try
                        {
                            result.Bindings = (object)bindings;
                        }
                        catch
                        {
                            // Do nothing
                        }
                    }
                }
            }

            if (!CommandList.ContainsKey(fullname))
            {
                CommandHandle handle = new CommandHandle();
                handle.CommandObject = result;
                handle.ExecuteMethod = executeMethod;
                handle.StatusMethod  = statusMethod;

                CommandList.Add(fullname, handle);
            }

            return(result);
        }
Пример #4
0
 private void element_EnterDown(object s, KeyRoutedEventArgs e)
 {
     foreach (KeyBind bind in KeyBinder.KeyBindList)
     {
         if (bind.CheckKeyDown(e.Key))
         {
             if (CommandList.ContainsKey(bind.CommandCode))
             {
                 CommandList[bind.CommandCode](bind);
             }
         }
     }
 }
 public void Invoke(string command, string[] args)
 {
     if (CommandList.ContainsKey(command))
     {
         try
         {
             CommandList[command].Invoke(args);
         }
         catch (Exception ex)
         {
             System.Windows.Forms.MessageBox.Show("Command execution error - " + command + "\n" + ex.Message);
         }
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Invalid command execution - " + command);
     }
 }
Пример #6
0
    void OnGameStart()
    {
        unitsCommanded.Clear();
        foreach (var unit in unitsOwned)
        {
            unitsCommanded.Add(unit);
        }

        // set units
        foreach (var unit in unitsCommanded)
        {
            if (!commands.ContainsKey(unit))
            {
                commands.Add(unit, null);
                unit.team              = team;
                unit.deathSubscribers += OnUnitDeath;
            }
        }

        ResetCommands();
    }