C# Code – 添加CollapseAllProjects命令

OnConnection()
{
    
    
// Get “Solution Explorer” command bar
    CommandBar slnCommandBar = GetCommandBarByName(Solution);
    
// Add a new command
    AddNamedCommand2(slnCommandBar, COLLAPSE_ALL_PROJECTS_COMMAND_NAME,
        
Collapse All ProjectsCollapse All Projectsfalse0, slnCommandBar.Controls.Count + 1);
}

QueryStatus()
{
    
    else if (commandName == GetCommandFullName(COLLAPSE_ALL_PROJECTS_COMMAND_NAME))
    {
        status 
= (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
        
return;
    }
}

Exec()
{
    
    else if (commandName == GetCommandFullName(COLLAPSE_ALL_PROJECTS_COMMAND_NAME))
    {
        CollapseAllProjects();

        handled = true;
        
return;
    }
}