Export (0) Print
Expand All

WindowConfigurations.Add Method

Creates a new named window configuration based on the current arrangement of windows, adds it to the WindowConfigurations collection, and retains it for future recall.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

WindowConfiguration Add(
	string Name
)

Parameters

Name
Type: System.String

Required. A string representing the name of the new window configuration.

You can save your current window layout in the Visual Studio environment as a named window configuration. The Add method allows you to save this configuration for later recall by using the Apply method.

void AddExample(_DTE dte)
{
    // Set references to all necessary objects.
    WindowConfigurations colWinConfig; 
    WindowConfiguration objWinConfig;

    colWinConfig = dte.WindowConfigurations;
    MessageBox.Show("Number of configurations: " + colWinConfig.Count);
    // List all saved named window configurations.
    FillMsg(colWinConfig);
    // reate a new window configuration.
    objWinConfig = colWinConfig.Add("NewLayout");
    FillMsg(colWinConfig);
    // Get rid of the new window configuration.
    objWinConfig.Delete();
    MessageBox.Show("Number of configurations: " + colWinConfig.Count);
    FillMsg(colWinConfig);
}

void FillMsg(WindowConfigurations colWinConfig )
{
    // Lists all currently available named window configurations.
    int lCtr;
    string strMsg = null;

    for (lCtr = 1; lCtr < colWinConfig.Count + 1; lCtr ++)
    {
        strMsg = strMsg + "Configuration name " + lCtr + ": " + 
        colWinConfig.Item(lCtr).Name + "\n"; 
    }
    strMsg = "Current Configurations: \n" + strMsg;
    MessageBox.Show(strMsg);
}

Show:
© 2014 Microsoft