Microsoft 9GD00001 Computer Accessories User Manual


 
Chapter 13: Extending Visual Studio 2010 395
", Shortcut: " + bindingStr +
"\n");
}
}
handled = true;
VB:
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)
outPane.OutputString(
"Command: " & cmd.Name &
", Shortcut: " & bindingStr &
Environment.NewLine)
End If
Next
handled = True
Notice how we set handled to true, letting VS know that the code recognized and
acted on the command. Besides letting users execute the Add-In, you want to ensure their
experience with the Add-In is logical and the command displays its status properly, as
you’ll learn about in the next section.
Setting Status with QueryStatus
While VS is working with your Add-In, it will call the QueryStatus method of
IDTCommandTarget to ensure it displays the command properly. Listing 13-4 shows
the default implementation of QueryStatus.
Listing 13-4 The QueryStatus method
C#:
public void QueryStatus(
string commandName,