示例#1
0
        public void create_popup_menu_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
            )
        {
            object[]        contextGUIDS = new object[] { };
            BARS.CommandBar host_bar     = ((BARS.CommandBars)_ssms.DTE2.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)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);

            if (new_command == null)
            {
                throw new Exception("SSMSW08 could not create command bar: " + item_text);
            }
            position = (position == 0 ? host_bar.Controls.Count + 1 : position);
            new_command.AddControl(host_bar, position);
            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);
        }
示例#2
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);
            }
        }
示例#3
0
        public void create_popup_menu_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
        )
        {
            object[] contextGUIDS = new object[] { };
            BARS.CommandBar host_bar = ((BARS.CommandBars)_ssms.DTE2.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)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);
            if (new_command == null)
            {
                throw new Exception("SSMSW08 could not create command bar: " + item_text);
            }
            position = (position == 0 ? host_bar.Controls.Count + 1 : position);
            new_command.AddControl(host_bar, position);
            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);
        }