392Microsoft Visual Studio 2010: A Beginner’s Guide

if (cmdBindings.Length > 0)

{

string bindingStr = string.Join(", ", cmdBindings);

outPane.OutputString( "Command: " + cmd.Name +

", Shortcut: " + bindingStr + "\n");

}

}

handled = true; return;

}

}

}

VB:

Public Sub Exec(

ByVal commandName As String,

ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object,

ByRef handled As Boolean) Implements IDTCommandTarget.Exec handled = False

If executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault Then If commandName =

"KeystrokeFinderVB.Connect.KeystrokeFinderVB" Then

Dim outWin As OutputWindow = _applicationObject.ToolWindows.OutputWindow

Dim outPane As OutputWindowPane = outWin.OutputWindowPanes.Add(

"Keyboard Shortcuts")

outPane.Activate()

For Each cmd As Command In _applicationObject.Commands

Dim cmdBindings As Object() =

CType(cmd.Bindings, Object())

If cmdBindings.Length > 0 Then

Dim bindingStr As String =

String.Join(", ", cmdBindings)

Page 415
Image 415
Microsoft 9GD00001 manual Microsoft Visual Studio 2010 a Beginner’s Guide