WindowConfiguration 接口
WindowConfiguration 对象表示 Visual Studio 环境中所有窗口的布局和配置。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
<GuidAttribute("41D02413-8A67-4C28-A980-AD7539ED415D")> _
Public Interface WindowConfiguration
[GuidAttribute("41D02413-8A67-4C28-A980-AD7539ED415D")]
public interface WindowConfiguration
[GuidAttribute(L"41D02413-8A67-4C28-A980-AD7539ED415D")]
public interface class WindowConfiguration
[<GuidAttribute("41D02413-8A67-4C28-A980-AD7539ED415D")>]
type WindowConfiguration = interface end
public interface WindowConfiguration
WindowConfiguration 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
Collection | 获取包含某个对象的集合,该对象支持此属性或包含在此代码构造中。 | |
DTE | 获取顶级扩展性对象。 | |
Name | 设置或获取对象的名称。 |
页首
方法
名称 | 说明 | |
---|---|---|
Apply | 调用以前保存的命名窗口配置。 | |
Delete | 从集合中移除窗口配置。 | |
Update | 更新集合,如同用户已打开“外接程序管理器”对话框一样,或将对象的窗口布局设置为当前窗口布局。 |
页首
备注
可以将 Visual Studio 环境中的当前窗口布局保存为命名窗口配置。 WindowConfiguration 对象表示此配置,您以后可通过使用 Apply 方法来重新调用该配置。
示例
Sub WinConfigExample1(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);
}