次の方法で共有


TaskItems2.DTE プロパティ

トップレベルの機能拡張オブジェクトを取得します。

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

構文

'宣言
ReadOnly Property DTE As DTE
    Get
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE

プロパティ値

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

実装

TaskItems.DTE

解説

Visual Studio では、DTE オブジェクトがオートメーション モデルのルート オブジェクトです。他のオブジェクト モデルでは、多くの場合、"アプリケーション" と呼ばれます。

この例では、2 つのタスク項目をタスク一覧に追加し、DTE オブジェクトを通じて取得したメイン ウィンドウのキャプションを含む、いくつかのプロパティをメッセージ ボックスに表示します。 このアドインの例を実行する方法の詳細については、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」を参照してください。

Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    TaskItems2DTEExample(_applicationObject)
End Sub
Sub TaskItems2DTEExample(ByVal dte As DTE2)
    Dim win As Window = _
    _applicationObject.Windows.Item(Constants.vsWindowKindTaskList)
    Dim TL As TaskList = CType(win.Object, TaskList)
    Dim TLItem As TaskItem
    Dim TLItems As TaskItems2
    TLItems = CType(TL.TaskItems, TaskItems2)
    ' Add a couple of tasks to the Task List.
    TLItem = TLItems.Add(" ", " ", "Test task 1." _
    , vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser _
    , True, , 10, , )
    TLItem = TLItems.Add(" ", " ", "Test task 2." _
    , vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment _
    , , , 20, , )
    ' List the total number of task list items after adding the new 
    ' task items.
    MsgBox("Task Item 1 description: " & TLItems.Item(2).Description)
    MsgBox("Total number of task items: " & TLItems.Count)
    ' Remove the second task item.
    ' The items list in reverse numeric order.
    MsgBox("Deleting the second task item")
    TLItems.Item(1).Delete()
    MsgBox("Total number of task items: " & TLItems.Count)
    MsgBox("The caption of the main window obtained through the  _
    DTE object is:" & vbCr & TLItems.DTE.MainWindow.Caption)
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    TaskItems2DTEExample(_applicationObject);
}
public void TaskItems2DTEExample(DTE2 dte)
{
    Window2 win = (Window2)_applicationObject.Windows.Item
(Constants.vsWindowKindTaskList);
    TaskList TL = (TaskList)win.Object;
    TaskItem TLItem;
    TaskItems2 TLItems;
    TLItems = (TaskItems2)TL.TaskItems;
    // Add a couple of tasks to the Task List.
    TLItem = TLItems.Add("MyTask", "MyTask1", "Test task 1."
, vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser
, true,null,10,true,true );
    TLItem = TLItems.Add("MyTask", "MyTask1", "Test task 2."
, vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment, 
true, null, 20, true, true);
    // List the total number of task list items after adding the new
    // task items.
    MessageBox.Show("Task Item 1 description: " 
+ TLItems.Item(2).Description);
    MessageBox.Show("Total number of task items: " 
+ TLItems.Count.ToString());
    // Remove the second task item.
    // The items list in reverse numeric order.
    MessageBox.Show("Deleting the second task item");
    TLItems.Item(1).Delete();
    MessageBox.Show("Total number of task items: " + TLItems.Count);
    MessageBox.Show("The caption of the main window obtained through 
the DTE object is:"+ "\n" +  TLItems.DTE.MainWindow.Caption);
}

.NET Framework セキュリティ

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

参照

参照

TaskItems2 インターフェイス

DTE オーバーロード

EnvDTE80 名前空間