この記事は翻訳者によって翻訳されたものです。 記事の文章にポインターを重ねると、原文のテキストが表示されます。 |
訳文
原文
|
ContextAttributes インターフェイス
[ダイナミック ヘルプ] ウィンドウのグローバル コンテキスト、またはウィンドウのコンテキストに関連付けられているすべての属性が含まれます。
アセンブリ: EnvDTE (EnvDTE.dll 内)
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