Поделиться через


WindowConfigurations Interface

The WindowConfigurations collection contains all named window configurations created for the environment.

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

Syntax

'Declaration
<GuidAttribute("E577442A-98E1-46C5-BD2E-D25807EC81CE")> _
Public Interface WindowConfigurations _
    Inherits IEnumerable
[GuidAttribute("E577442A-98E1-46C5-BD2E-D25807EC81CE")]
public interface WindowConfigurations : IEnumerable
[GuidAttribute(L"E577442A-98E1-46C5-BD2E-D25807EC81CE")]
public interface class WindowConfigurations : IEnumerable
[<GuidAttribute("E577442A-98E1-46C5-BD2E-D25807EC81CE")>]
type WindowConfigurations =  
    interface
        interface IEnumerable
    end
public interface WindowConfigurations extends IEnumerable

The WindowConfigurations type exposes the following members.

Properties

  Name Description
Public property ActiveConfigurationName Gets the name of the currently active window configuration.
Public property Count Gets a value indicating the number of objects in the collection.
Public property DTE Gets the top-level extensibility object.
Public property Parent Gets the immediate parent object of a WindowConfigurations collection.

Top

Methods

  Name Description
Public method Add 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.
Public method GetEnumerator Gets an enumeration for items in a collection.
Public method Item Returns an indexed member of a WindowConfigurations collection.

Top

Remarks

You can save your current window layout in the Visual Studio environment as a named window configuration. The WindowConfigurations collection contains all such configurations.

Examples

Sub WinConfigurationsExample(ByVal dte As DTE)
    ' This example lists all currently available named window 
    ' configurations.
    ' Set references to all necessary objects.
    Dim colWinConfig As WindowConfigurations
    Dim objWinConfig As WindowConfiguration

    colWinConfig = dte.WindowConfigurations

    MsgBox("Number of configurations: " & colWinConfig.Count)
    ' List all saved named window configurations
    FillMsg(colWinConfig)
    ' Create a new window configuration.
    objWinConfig = colWinConfig.Add("NewLayout")
    FillMsg(colWinConfig)
    ' Get rid of the new window configuration.
    objWinConfig.Delete()
    MsgBox("Number of configurations: " & colWinConfig.Count)
    FillMsg(colWinConfig)
End Sub

Sub FillMsg(ByVal colWinConfig As Object)
    ' Lists all currently available named window configurations.
    Dim lCtr As Integer
    Dim strMsg As String

    For lCtr = 1 To colWinConfig.Count
    strMsg = strMsg & "Configuration name " & lCtr & ": " & _
    colWinConfig.Item(lCtr).Name & vbCr
    Next lCtr
    strMsg = "Current Configurations: " & vbCr & strMsg
    MsgBox(strMsg)
End Sub
void WinConfigExample1(_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);
    // Create 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);
}

See Also

Reference

EnvDTE Namespace

Other Resources

WindowConfiguration Creation Example

WindowConfiguration Selection Example