예제 #1
0
        public vsCommandStatus QueryStatus(string commandName)
        {
            vsCommandStatus status = vsCommandStatus.vsCommandStatusNinched | vsCommandStatus.vsCommandStatusSupported;

            if (this.CommandList.ContainsKey(commandName))
            {
                CommandHandle handle = this.CommandList[commandName];

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

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

            return(status);
        }
예제 #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);
        }