Chapter 13: Extending Visual Studio 2010 | 387 |
Dim command As Command = commands.AddNamedCommand2(
_addInInstance, "KeystrokeFinderVB", "KeystrokeFinderVB",
"Executes the command for KeystrokeFinderVB", True, 59, Nothing, CType(vsCommandStatus.vsCommandStatusSupported,
Integer) + CType(vsCommandStatus.vsCommandStatusEnabled,
Integer),
vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton)
command.AddControl(toolsPopup.CommandBar, 1) Catch argumentException As System.ArgumentException End Try
End If
End Sub
Dissecting Listing
C#:
_applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst;
VB:
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
The remaining code in OnConnection sets up the menu item under the Tools menu, as directed by choosing to build a command UI, shown in Figure