WindowConfigurations 接口
WindowConfigurations 集合包含为环境创建的所有命名窗口配置。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
<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
WindowConfigurations 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
ActiveConfigurationName | 获取当前处于活动状态的窗口配置的名称。 | |
Count | 获取一个值,该值指示集合中对象的数目。 | |
DTE | 获取顶级扩展性对象。 | |
Parent | 获取 WindowConfigurations 集合的直接父对象。 |
页首
方法
名称 | 说明 | |
---|---|---|
Add | 基于窗口的当前排列创建新的命名窗口配置,将该配置添加到 WindowConfigurations 集合,并保留以备将来重新调用。 | |
GetEnumerator | 获取集合中项的枚举。 | |
Item | 返回 WindowConfigurations 集合的一个索引成员。 |
页首
备注
可以将 Visual Studio 环境中的当前窗口布局保存为命名窗口配置。 WindowConfigurations 集合包含所有这样的配置。
示例
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);
}