Connect.cs
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification
/// that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification
that the Add-in is being loaded.
Root object of the host application.
Describes how the Add-in is being loaded.
Object representing this Add-in.
Implements the OnConnection method of the IDTExtensibility2 interface . Receives notification that the Add - in is being loaded . Root object of the host application . Describes how the Add - in is being loaded . Object representing this Add - in .
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;
            if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            {
                Commands2 commands = (Commands2)_applicationObject.Commands;
                string toolsMenuName = "Tools";
                object[] contextGUIDs = new object[] { };
                CommandBar menuBarCommandBar = ((CommandBars)_applicationObject.CommandBars)["MenuBar"];
                CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
                CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;
                try
                {
                    Command command = commands.AddNamedCommand2(
                        _addInInstance,
                        "SSMSQueryHistory",
                        "SSMS Query History",
                        "Opens the SSMS Query History search window",
                        true,
                        183,
                        ref contextGUIDs,
                        (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                        (int)vsCommandStyle.vsCommandStylePictAndText,
                        vsCommandControlType.vsCommandControlTypeButton);
                    if ((command != null) && (toolsPopup != null))
                    {
                        command.AddControl(toolsPopup.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException)
                {
                }
            }
        }
public void OnConnection ( object application , ext_ConnectMode connectMode , object addInInst , ref Array custom ) { _applicationObject = ( DTE2 ) application ; _addInInstance = ( AddIn ) addInInst ; if ( connectMode == ext_ConnectMode . ext_cm_UISetup ) { Commands2 commands = ( Commands2 ) _applicationObject . Commands ; string toolsMenuName = " " ; object [ ] contextGUIDs = new object [ ] { } ; CommandBar menuBarCommandBar = ( ( CommandBars ) _applicationObject . CommandBars ) [ " " ] ; CommandBarControl toolsControl = menuBarCommandBar . Controls [ toolsMenuName ] ; CommandBarPopup toolsPopup = ( CommandBarPopup ) toolsControl ; try { Command command = commands . AddNamedCommand2 ( _addInInstance , " " , " " , " " , true , 183 , ref contextGUIDs , ( int ) vsCommandStatus . vsCommandStatusSupported + ( int ) vsCommandStatus . vsCommandStatusEnabled , ( int ) vsCommandStyle . vsCommandStylePictAndText , vsCommandControlType . vsCommandControlTypeButton ) ; if ( ( command != null ) && ( toolsPopup != null ) ) { command . AddControl ( toolsPopup . CommandBar , 1 ) ; } } catch ( System . ArgumentException ) { } } }
<summary>Implements the OnConnection method of the IDTExtensibility2 interface.
<summary > Implements the OnConnection method of the IDTExtensibility2 interface .
application
object
connectMode
ext_ConnectMode
addInInst
object
Array
ref