You can associate some state variable with your buttons wich can express whether your button should be enabled in the recent state of your Add-In. When your Add-In itinializes, you should set the state as you whish. In the query you can check the recent state of your Add-In and set the buttuns into their proper enabled / unsupported state.
The state can be modified through the QueryStatus
method of the IDTCommandTarget
interface (If your Add-In is loaded).
Default template implementation:
public void QueryStatus(string commandName, vsCommandStatusTextWanted neededText, ref vsCommandStatus status, ref object commandText)
{
if(neededText == vsCommandStatusTextWanted.vsCommandStatusTextWantedNone)
{
if(commandName == "YourAddin.Connect.YourAddinCommandName")
{
status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported|vsCommandStatus.vsCommandStatusEnabled;
return;
}
}
}
You can disable a button by setting the status to vsCommandStatus.vsCommandStatusUnsupported