私はしばらくの間この問題を抱えていて、どこにも解決策を見つけることができません。現在、Visual Studio 2010用のアドイン(C#を使用)を作成しています。VSメニューバーに新しいメニューを追加しました。このメニューには、「ログイン」や「ログアウト」などのコマンドがあります。強制したい動作は、両方のコマンドが表示されることですが、最初は「ログイン」のみが有効になり、「ログアウト」は最初は無効になります。
これは、OnConnection()メソッドの次のコードを使用して実現します。
LoginCommand = applicationObject.Commands.AddNamedCommand(
addInInstance,
LOGIN_NAME,
LOGIN_CAPTION,
LOGIN_TOOLTIP,
true, 59,
ref contextUIGuids,
(int)(vsCommandStatus.vsCommandStatusSupported |
vsCommandStatus.vsCommandStatusEnabled)
);
LogoutCommand = applicationObject.Commands.AddNamedCommand(
addInInstance,
LOGOUT_NAME,
LOGOUT_CAPTION,
LOGOUT_TOOLTIP,
true, 59,
ref contextUIGuids,
(int)(vsCommandStatus.vsCommandStatusSupported)
);
「login」コマンドを発行して正常にログインした場合は、逆に、メニューで「login」コマンドが無効になり、「logout」が有効になるようにします。ログアウトするまでです。
そして、これは私が立ち往生しているところです。コマンドの状態切り替えをどこでどのように正確に実装するかがわかりません。これはQueryStatus()メソッドで処理する必要があると思いますが、このトピックに関するMicrosoftのドキュメントは、あまり役に立たないか、目を見張るものがあります。