次の方法で共有


WindowConfigurations.Add メソッド

現在のウィンドウの配置状態に基づいて新しい名前付きウィンドウ構成を作成し、その構成を WindowConfigurations コレクションに追加して、今後の呼び出しのために保持します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Function Add ( _
    Name As String _
) As WindowConfiguration
WindowConfiguration Add(
    string Name
)
WindowConfiguration^ Add(
    [InAttribute] String^ Name
)
abstract Add : 
        Name:string -> WindowConfiguration
function Add(
    Name : String
) : WindowConfiguration

パラメーター

  • Name
    型 : String

    必須。 新しいウィンドウ構成の名前を表す文字列。

戻り値

型 : EnvDTE.WindowConfiguration
WindowConfiguration オブジェクト。

解説

現在のウィンドウのレイアウトに名前を付けて、ウィンドウ構成として Visual Studio 環境に保存できます。 Add メソッドを使用してこの構成を保存しておけば、Apply メソッドを使用して後で呼び出すことができます。

Sub AddExample(ByVal dte As DTE)
    ' 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 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);
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

WindowConfigurations インターフェイス

EnvDTE 名前空間

その他の技術情報

WindowConfiguration の作成例

WindowConfiguration の選択の例