
Chapter 13: Extending Visual Studio 2010 | 391 |
As you may recall, the OnConnection method assigned the main application object to _applicationObject, a field of the Connect class. This is important because now you have access to the main application object, and you’ll see how it’s used in the next section, which shows you how to execute your
Implementing the Exec Method
Whenever a user starts your
for this section is to list all VS commands and their associated shortcut keys. The list of commands and shortcuts will be displayed in the VS Output window. Listing
Listing 13-3 Implementing the Exec method
C#:
public void Exec(
string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false; if(executeOption ==
vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if (commandName == "KeystrokeFinder.Connect.KeystrokeFinder")
{
OutputWindow outWin = _applicationObject.ToolWindows.OutputWindow;
OutputWindowPane outPane = outWin.OutputWindowPanes.Add(
"Keyboard Shortcuts"); outPane.Activate();
foreach (Command cmd in _applicationObject.Commands)
{
object[] cmdBindings = cmd.Bindings as object[];