コード例 #1
0
ファイル: Plugin.cs プロジェクト: xatazch/gitextensions
        private static MsoButtonStyle CommandStyleToButtonStyle(vsCommandStyle commandStyle)
        {
            switch (commandStyle)
            {
            case vsCommandStyle.vsCommandStylePict:
                return(MsoButtonStyle.msoButtonIcon);

            case vsCommandStyle.vsCommandStyleText:
                return(MsoButtonStyle.msoButtonCaption);

            default:
                return(MsoButtonStyle.msoButtonIconAndCaption);
            }
        }
コード例 #2
0
ファイル: Connect.cs プロジェクト: jrowies/dsmaddin
        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);
        }
コード例 #3
0
        private Command GetCommand(string commandName, string caption, string tooltip, int iconIndex,
                                   vsCommandStyle commandStyle, Commands2 commands)
        {
            var contextGUIDS = new object[] {};

            // Add command
            Command command = GetCommand(commandName);

            if (_visualStudioCommands.ContainsKey(commandName))
            {
                return(command);
            }

            if (command == null && iconIndex > 0)
            {
                try
                {
                    command = commands.AddNamedCommand2(_addIn,
                                                        commandName, caption, tooltip, false, iconIndex,
                                                        ref contextGUIDS,
                                                        (int)vsCommandStatus.vsCommandStatusSupported |
                                                        (int)vsCommandStatus.vsCommandStatusEnabled,
                                                        (int)commandStyle,
                                                        vsCommandControlType.vsCommandControlTypeButton);
                }
                catch (Exception)
                {
                }
            }

            if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
            {
                command = commands.AddNamedCommand2(_addIn,
                                                    commandName, caption, tooltip, true, -1, ref contextGUIDS,
                                                    (int)vsCommandStatus.vsCommandStatusSupported +
                                                    (int)vsCommandStatus.vsCommandStatusEnabled,
                                                    (int)commandStyle,
                                                    vsCommandControlType.vsCommandControlTypeButton);
            }

            if (command != null)
            {
                _visualStudioCommands[commandName] = command;
            }
            return(command);
        }
コード例 #4
0
ファイル: Connect.cs プロジェクト: imzjy/internals-viewer
        /// <summary>
        /// Adds a command bar button.
        /// </summary>
        /// <param name="commands">The commands object.</param>
        /// <param name="commandBar">The command bar.</param>
        /// <param name="commandName">Name of the command.</param>
        /// <param name="description">The description.</param>
        /// <param name="picture">The picture.</param>
        /// <param name="mask">The mask.</param>
        /// <returns></returns>
        private CommandBarButton AddCommandBarButton(Commands2 commands, CommandBar commandBar, string commandName, string description, Bitmap picture, Bitmap mask)
        {
            Command command = null;

            object[] contextGUIDS = null;

            try
            {
                command = commands.Item(addInInstance.ProgID + "." + commandName, 0);
            }
            catch
            {
            }

            if (command == null)
            {
                vsCommandStyle commandStyle = vsCommandStyle.vsCommandStylePict;

                command = commands.AddNamedCommand2(addInInstance,
                                                    commandName,
                                                    string.Empty,
                                                    description,
                                                    true,
                                                    null,
                                                    ref contextGUIDS,
                                                    (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                                                    (int)commandStyle,
                                                    vsCommandControlType.vsCommandControlTypeButton);
            }

            CommandBarButton control = (CommandBarButton)command.AddControl(commandBar, commandBar.Controls.Count + 1);

            control.BeginGroup = true;

            if (picture != null)
            {
                control.Picture = (StdPicture)ImageConverter.GetIPictureDispFromImage(picture);
                control.Mask    = (StdPicture)ImageConverter.GetIPictureDispFromImage(mask);
            }

            return(control);
        }
コード例 #5
0
ファイル: Connect.cs プロジェクト: imzjy/internals-viewer
        /// <summary>
        /// Adds the command bar popup (menu item).
        /// </summary>
        /// <param name="commands">The commands object.</param>
        /// <param name="commandBar">The command bar.</param>
        /// <param name="name">The name.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="description">The description.</param>
        /// <param name="picture">The picture.</param>
        /// <param name="mask">The mask.</param>
        private void AddCommandBarPopup(Commands2 commands, CommandBarPopup commandBar, string name, string caption, string description, Bitmap picture, Bitmap mask)
        {
            Command command = null;

            object[] contextGUIDS = null;

            try
            {
                command = commands.Item(addInInstance.ProgID + "." + name, 0);
            }
            catch
            {
            }

            if (command == null)
            {
                vsCommandStyle commandStyle = (picture == null) ? vsCommandStyle.vsCommandStyleText : vsCommandStyle.vsCommandStylePictAndText;

                command = commands.AddNamedCommand2(addInInstance,
                                                    name,
                                                    caption,
                                                    description,
                                                    true,
                                                    null,
                                                    ref contextGUIDS,
                                                    (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                                                    (int)commandStyle,
                                                    vsCommandControlType.vsCommandControlTypeButton);
            }

            CommandBarButton control = (CommandBarButton)command.AddControl(commandBar.CommandBar, 1);

            control.Caption = caption;

            if (picture != null)
            {
                control.Picture = (StdPicture)ImageConverter.GetIPictureDispFromImage(picture);
                control.Mask    = (StdPicture)ImageConverter.GetIPictureDispFromImage(mask);
            }
        }
コード例 #6
0
        public void create_bar_command(
            string host_menu_bar_name,
            string command_name,
            string item_text,
            string tooltip_text,
            int position,
            menu_command_querystatus_handler querystatus_handler,
            menu_command_exec_handler exec_handler,
            Bitmap picture,
            bool beginGroup
            )
        {
            try
            {
                object[] contextGUIDS = new object[] { };
                RemoveCommandIfAlreadyExits(command_name);

                vsCommandStyle commandStyle = (picture == null) ? vsCommandStyle.vsCommandStyleText : vsCommandStyle.vsCommandStylePictAndText;

                BARS.CommandBar host_bar    = (BARS.CommandBar)((BARS.CommandBars)VSI.ServiceCache.ExtensibilityModel.CommandBars)[host_menu_bar_name];
                Command         new_command = _SSMS_commands_collection.AddNamedCommand2(_ssms.addin, command_name, item_text, tooltip_text, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)commandStyle, vsCommandControlType.vsCommandControlTypeButton);
                if (new_command != null)
                {
                    position = (position == 0 ? host_bar.Controls.Count + 1 : position);
                    BARS.CommandBarButton control = (BARS.CommandBarButton)new_command.AddControl(host_bar, position);
                    control.BeginGroup  = beginGroup;
                    control.TooltipText = tooltip_text.Substring(0, tooltip_text.Length > 255 ? 255 : tooltip_text.Length);
                    menu_command_handlers handlers = new menu_command_handlers();
                    handlers.querystatus_handler = querystatus_handler == null ? this._default_querystatus_handler : querystatus_handler;
                    handlers.exec_handler        = exec_handler == null ? this._default_exec_handler : exec_handler;
                    this._addin_menu_commands_dictonary.Add(_ssms.addin.ProgID + "." + command_name, handlers);
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "Exception at create_bar_command");
                System.Diagnostics.Debug.Print(e.Message);
            }
        }
コード例 #7
0
ファイル: Plugin.cs プロジェクト: chafnan/gitextensions
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
                                             string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
            {
                return;
            }

            // Get commands collection
            var commands     = (Commands2)m_application.Commands;
            var contextGUIDS = new object[] {};

            // Add command
            Command command = GetCommand(commandName);

            if (!m_visualStudioCommands.ContainsKey(commandName))
            {
                if (command == null)
                {
                    if (iconIndex > 0)
                    {
                        try
                        {
                            command = commands.AddNamedCommand2(m_addIn,
                                                                commandName, caption, tooltip, false, iconIndex,
                                                                ref contextGUIDS,
                                                                (int)vsCommandStatus.vsCommandStatusSupported +
                                                                (int)vsCommandStatus.vsCommandStatusEnabled,
                                                                (int)commandStyle,
                                                                vsCommandControlType.vsCommandControlTypeButton);
                            m_visualStudioCommands[commandName] = command;
                        }
                        catch
                        {
                        }
                    }

                    if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
                    {
                        command = commands.AddNamedCommand2(m_addIn,
                                                            commandName, caption, tooltip, true, -1, ref contextGUIDS,
                                                            (int)vsCommandStatus.vsCommandStatusSupported +
                                                            (int)vsCommandStatus.vsCommandStatusEnabled,
                                                            (int)commandStyle,
                                                            vsCommandControlType.vsCommandControlTypeButton);
                        m_visualStudioCommands[commandName] = command;
                    }
                }
            }
            if (command != null && bar != null)
            {
                if (!HasCommand(bar, caption))
                {
                    OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
                    command.AddControl(bar, insertIndex);
                }
            }
        }
コード例 #8
0
ファイル: Plugin.cs プロジェクト: rschoening/gitextensions
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
                                             string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
                return;

            // Get commands collection
            var commands = (Commands2)m_application.Commands;
            var contextGUIDS = new object[] { };

            // Add command
            Command command = GetCommand(commandName);
            if (!m_visualStudioCommands.ContainsKey(commandName))
            {
                if (command == null)
                {
                    if (iconIndex > 0)
                    {
                        try
                        {
                            command = commands.AddNamedCommand2(m_addIn,
                                                                commandName, caption, tooltip, false, iconIndex,
                                                                ref contextGUIDS,
                                                                (int)vsCommandStatus.vsCommandStatusSupported +
                                                                (int)vsCommandStatus.vsCommandStatusEnabled,
                                                                (int)commandStyle,
                                                                vsCommandControlType.vsCommandControlTypeButton);
                        }
                        catch
                        {
                        }
                    }

                    if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
                    {
                        command = commands.AddNamedCommand2(m_addIn,
                                                            commandName, caption, tooltip, true, -1, ref contextGUIDS,
                                                            (int)vsCommandStatus.vsCommandStatusSupported +
                                                            (int)vsCommandStatus.vsCommandStatusEnabled,
                                                            (int)commandStyle,
                                                            vsCommandControlType.vsCommandControlTypeButton);
                    }
                }
                if (command != null)
                {
                    m_visualStudioCommands[commandName] = command;
                }
            }
            if (command != null && bar != null)
            {
                if (!HasCommand(bar, caption))
                {
                    OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
                    command.AddControl(bar, insertIndex);
                }
            }
        }
コード例 #9
0
ファイル: Plugin.cs プロジェクト: xatazch/gitextensions
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
                                             string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle, bool beginGroup)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
            {
                return;
            }

            // Get commands collection
            var commands = (Commands2)_application.Commands;
            var command  = GetCommand(commandName, caption, tooltip, iconIndex, commandStyle, commands);

            if (command == null)
            {
                return;
            }
            if (!HasCommand(bar, caption))
            {
#if DEBUG
                OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
#endif
                var control = (CommandBarButton)command.AddControl(bar, insertIndex);
                control.Style      = CommandStyleToButtonStyle(commandStyle);
                control.BeginGroup = beginGroup;
            }
        }
コード例 #10
0
ファイル: Plugin.cs プロジェクト: slaut/gitextensions
 private static MsoButtonStyle CommandStyleToButtonStyle(vsCommandStyle commandStyle)
 {
     switch (commandStyle)
     {
         case vsCommandStyle.vsCommandStylePict:
             return MsoButtonStyle.msoButtonIcon;
         case vsCommandStyle.vsCommandStyleText:
             return MsoButtonStyle.msoButtonCaption;
         default:
             return MsoButtonStyle.msoButtonIconAndCaption;
     }
 }
コード例 #11
0
ファイル: Plugin.cs プロジェクト: HuChundong/gitextensions
        private Command GetCommand(string commandName, string caption, string tooltip, int iconIndex,
            vsCommandStyle commandStyle, Commands2 commands)
        {
            var contextGUIDS = new object[] {};

            // Add command
            Command command = GetCommand(commandName);
            if (_visualStudioCommands.ContainsKey(commandName))
                return command;

            if (command == null && iconIndex > 0)
            {
                try
                {
                    command = commands.AddNamedCommand2(_addIn,
                        commandName, caption, tooltip, false, iconIndex,
                        ref contextGUIDS,
                        (int) vsCommandStatus.vsCommandStatusSupported |
                        (int) vsCommandStatus.vsCommandStatusEnabled,
                        (int) commandStyle,
                        vsCommandControlType.vsCommandControlTypeButton);
                }
                catch (Exception)
                {
                }
            }

            if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
            {
                command = commands.AddNamedCommand2(_addIn,
                    commandName, caption, tooltip, true, -1, ref contextGUIDS,
                    (int) vsCommandStatus.vsCommandStatusSupported +
                    (int) vsCommandStatus.vsCommandStatusEnabled,
                    (int) commandStyle,
                    vsCommandControlType.vsCommandControlTypeButton);
            }

            if (command != null)
            {
                _visualStudioCommands[commandName] = command;
            }
            return command;
        }
コード例 #12
0
ファイル: Plugin.cs プロジェクト: HuChundong/gitextensions
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
                                             string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle, bool beginGroup)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
                return;

            // Get commands collection
            var commands = (Commands2)_application.Commands;
            var command = GetCommand(commandName, caption, tooltip, iconIndex, commandStyle, commands);
            if (command == null)
                return;
            if (!HasCommand(bar, caption))
            {
#if DEBUG
                OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
#endif
                var control = (CommandBarButton)command.AddControl(bar, insertIndex);
                control.Style = CommandStyleToButtonStyle(commandStyle);
                control.BeginGroup = beginGroup;
            }
        }
コード例 #13
0
ファイル: Connect.cs プロジェクト: jrowies/dsmaddin
        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;
        }
コード例 #14
0
ファイル: Plugin.cs プロジェクト: gdennie/gitextensions
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
            string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
                return;

            // Get commands collection
            Commands2 commands = (Commands2)m_application.Commands;
            object[] contextGUIDS = new object[] { };

            // Add command
            Command command = GetCommand(commandName);
            if (command == null)
            {
                if (iconIndex > 0)
                {
                    try
                    {
                        command = commands.AddNamedCommand2(m_addIn, commandName,
                                    caption, tooltip, false, iconIndex, ref contextGUIDS,
                                    (int)vsCommandStatus.vsCommandStatusSupported +
                                    (int)vsCommandStatus.vsCommandStatusEnabled,
                                    (int)commandStyle,
                                    vsCommandControlType.vsCommandControlTypeButton);
                    }
                    catch
                    {
                    }
                }

                if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
                {
                    command = commands.AddNamedCommand2(m_addIn, commandName,
                            caption, tooltip, true, -1, ref contextGUIDS,
                            (int)vsCommandStatus.vsCommandStatusSupported +
                            (int)vsCommandStatus.vsCommandStatusEnabled,
                            (int)commandStyle,
                            vsCommandControlType.vsCommandControlTypeButton);
                }
            }
            if (command != null && bar != null)
            {
                if (!HasCommand(bar, caption))
                    command.AddControl(bar, insertIndex);
            }
        }