Beispiel #1
0
        public void AddConsoleOnlyCommand(string commandName, string itemName, string description)
        {
            var contextGuids = new object[] {};
            var commands     = (Commands2)m_application.Commands;

            try
            {
                int commandStatus = (int)vsCommandStatus.vsCommandStatusSupported +
                                    (int)vsCommandStatus.vsCommandStatusEnabled;

                var commandStyle = (int)vsCommandStyle.vsCommandStylePictAndText;
                vsCommandControlType controlType = vsCommandControlType.vsCommandControlTypeButton;

                // TODO: [jt] I think the context guids here are the key to enable commands on just a menu and not through the command line interface.
                Command command = commands.AddNamedCommand2(m_addIn,
                                                            commandName,
                                                            itemName,
                                                            description,
                                                            true,
                                                            59,
                                                            ref contextGuids,
                                                            commandStatus,
                                                            commandStyle,
                                                            controlType);
                m_visualStudioCommands[commandName] = command;
            }
            catch (ArgumentException)
            {
                Log.Debug("Tried to register the command \"{0}\" twice!", commandName);
            }
        }
Beispiel #2
0
        private Command AddCommand(CommandBar toolbar, string key, string name, string tooltip,
                                   vsCommandControlType ctype, int toolbarpos, vsCommandStyle cmdstyle, int faceID, out object controlCreated)
        {
            object[]  contextGUIDS = new object[] { };
            Commands2 commands     = (Commands2)_applicationObject.Commands;

            // Add a command to the Commands collection:
            Command command = null;

            try
            {
                command = commands.Item(String.Format("{0}.{1}", _addInInstance.ProgID, key), -1);
            }
            catch (ArgumentException)
            {
            }

            if (command == null)
            {
                command = commands.AddNamedCommand2(_addInInstance, key, name, tooltip, false, faceID, ref contextGUIDS,
                                                    (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                                                    (int)cmdstyle, ctype);
            }

            if (command != null && toolbar != null && toolbarpos > 0)
            {
                controlCreated = command.AddControl(toolbar, toolbarpos);
                CommandBarControl aux = controlCreated as CommandBarControl;
                if (aux != null)
                {
                    _controlsCreated.Add(aux);
                }

                //if (controlCreated is CommandBarButton)
                //{
                //  PictureManager.CommandButtons.Add(key, controlCreated as CommandBarButton);
                //  PictureManager.SetPicture(key, true);
                //}
            }
            else
            {
                controlCreated = null;
            }

            return(command);
        }
Beispiel #3
0
        public EnvDTE.Command AddNamedCommand2(EnvDTE.AddIn AddInInstance, string Name, string ButtonText, string Tooltip, bool MSOButton, [System.Runtime.InteropServices.OptionalAttribute]object Bitmap, [System.Runtime.InteropServices.OptionalAttribute]ref object[] ContextUIGUIDs, int vsCommandStatusValue = 3, int CommandStyleFlags = 3, vsCommandControlType ControlType = vsCommandControlType.vsCommandControlTypeButton)
        {
            MockCommand command = new MockCommand(AddInInstance, Name);

            return command;
        }
Beispiel #4
0
        private Command AddCommand(CommandBar toolbar, string key, string name, string tooltip,
            vsCommandControlType ctype, int toolbarpos, vsCommandStyle cmdstyle, int faceID, out object controlCreated)
        {
            object[] contextGUIDS = new object[] { };
              Commands2 commands = (Commands2)_applicationObject.Commands;

              // Add a command to the Commands collection:
              Command command = null;
              try
              {
            command = commands.Item(String.Format("{0}.{1}", _addInInstance.ProgID, key), -1);
              }
              catch (ArgumentException)
              {
              }

              if (command == null)
              {
            command = commands.AddNamedCommand2(_addInInstance, key, name, tooltip, false, faceID, ref contextGUIDS,
              (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
              (int)cmdstyle, ctype);
              }

              if (command != null && toolbar != null && toolbarpos > 0)
              {
            controlCreated = command.AddControl(toolbar, toolbarpos);
            CommandBarControl aux = controlCreated as CommandBarControl;
            if (aux != null)
              _controlsCreated.Add(aux);

            //if (controlCreated is CommandBarButton)
            //{
            //  PictureManager.CommandButtons.Add(key, controlCreated as CommandBarButton);
            //  PictureManager.SetPicture(key, true);
            //}
              }
              else
            controlCreated = null;

              return command;
        }