ContextAttributes インターフェイス

[ダイナミック ヘルプ] ウィンドウのグローバル コンテキスト、またはウィンドウのコンテキストに関連付けられているすべての属性が含まれます。

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

構文

'宣言
<GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")> _
Public Interface ContextAttributes _
    Inherits IEnumerable
[GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")]
public interface ContextAttributes : IEnumerable
[GuidAttribute(L"33C5EBB8-244E-449D-9CEE-FAD70A774E59")]
public interface class ContextAttributes : IEnumerable
[<GuidAttribute("33C5EBB8-244E-449D-9CEE-FAD70A774E59")>]
type ContextAttributes =  
    interface
        interface IEnumerable
    end
public interface ContextAttributes extends IEnumerable

ContextAttributes 型で公開されるメンバーは以下のとおりです。

プロパティ

  名前 説明
パブリック プロパティ Count ContextAttributes コレクション内のオブジェクトの数を示す値を取得します。
パブリック プロパティ DTE トップレベルの機能拡張オブジェクトを取得します。
パブリック プロパティ HighPriorityAttributes High Priority 属性コレクションを取得します。
パブリック プロパティ Parent ContextAttributes コレクションの直接の親オブジェクトを取得します。
パブリック プロパティ Type オブジェクト型を示す定数を取得します。

このページのトップへ

メソッド

  名前 説明
パブリック メソッド Add ContextAttributes コレクションに属性名と属性値のペアを追加します。
パブリック メソッド GetEnumerator() コレクションを反復処理する列挙子を返します。 (IEnumerable から継承されます。)
パブリック メソッド GetEnumerator() コレクション内の項目の列挙子を返します。
パブリック メソッド Item ContextAttributes コレクションの項目である ContextAttribute オブジェクトを返します。
パブリック メソッド Refresh 属性コレクションの内容を最新の状態にします。

このページのトップへ

解説

DTE.ContextAttributes の場合、グローバル コンテキスト バッグに作用します。トピックの並べ替えでは、優先順位が最も低くなります。

Window.ContextAttributes の場合、ウィンドウのコンテキスト バッグに作用します。 ツール ウィンドウの場合、各属性はウィンドウにフォーカスがあるときにだけ有効です。 エディターとデザイナーの場合、エディターが最後にアクティブな MDI 子フォームである限り、各属性は有効です。 HighPriorityAttributes プロパティに true を設定すると、属性は常に有効になり、優先順位が最も高くなります。

オブジェクトをフェッチするだけでは ContextAttributes コレクションは更新されないため、コレクションを取得した後に、ContextAttributes.Refresh を呼び出して、属性のコレクションを確実に最新の状態にする必要があります。 ただし、属性の追加や削除を行うと、ContextAttributes コレクションは暗黙的に更新されるため、追加または削除の操作を行うと最新の状態になります。

Sub ContextAttributesExample()
   ' Get a reference to Solution Explorer.
   Dim SolnEx As Window = DTE.Windows.Item _
   (Constants.vsWindowKindSolutionExplorer)
   Dim CA As ContextAttribute

   ' List the current attributes associated with Solution Explorer.
   ListAttr(SolnEx, CA)

   ' Associate a new F1 keyword with Solution Explorer.
   SolnEx.ContextAttributes.Add("ANewKeyword", 900, _
   vsContextAttributeType.vsContextAttributeLookupF1)
   ListAttr(SolnEx, CA)

   ' Delete the new F1 keyword from Solution Explorer.
   SolnEx.ContextAttributes.Item(3).Remove()
   ListAttr(SolnEx, CA)
End Sub

Sub ListAttr(ByVal SolnEx As Object, ByVal CA As ContextAttribute)
   ' Support function for CATest(). Lists the current attributes 
   ' associated with Solution Explorer.
   Dim msg As String

   MsgBox("Number of context attributes in Solution Explorer: " & _
   SolnEx.ContextAttributes.Count)
   For Each CA In SolnEx.ContextAttributes
      msg = msg & CA.Name & Chr(13)
   Next
   MsgBox(msg)
   msg = ""
End Sub

参照

参照

EnvDTE 名前空間