Condividi tramite


Metodo TaskItems2.Add (String, String, String, vsTaskPriority, Object, Boolean, String, Int32, Boolean, Boolean)

Aggiunge una nuova attività all'oggetto TaskList.

Spazio dei nomi:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Sintassi

'Dichiarazione
Function Add ( _
    Category As String, _
    SubCategory As String, _
    Description As String, _
    Priority As vsTaskPriority, _
    Icon As Object, _
    Checkable As Boolean, _
    File As String, _
    Line As Integer, _
    CanUserDelete As Boolean, _
    FlushItem As Boolean _
) As TaskItem
TaskItem Add(
    string Category,
    string SubCategory,
    string Description,
    vsTaskPriority Priority,
    Object Icon,
    bool Checkable,
    string File,
    int Line,
    bool CanUserDelete,
    bool FlushItem
)
TaskItem^ Add(
    [InAttribute] String^ Category, 
    [InAttribute] String^ SubCategory, 
    [InAttribute] String^ Description, 
    [InAttribute] vsTaskPriority Priority, 
    [InAttribute] Object^ Icon, 
    [InAttribute] bool Checkable, 
    [InAttribute] String^ File, 
    [InAttribute] int Line, 
    [InAttribute] bool CanUserDelete, 
    [InAttribute] bool FlushItem
)
abstract Add : 
        Category:string * 
        SubCategory:string * 
        Description:string * 
        Priority:vsTaskPriority * 
        Icon:Object * 
        Checkable:bool * 
        File:string * 
        Line:int * 
        CanUserDelete:bool * 
        FlushItem:bool -> TaskItem 
function Add(
    Category : String, 
    SubCategory : String, 
    Description : String, 
    Priority : vsTaskPriority, 
    Icon : Object, 
    Checkable : boolean, 
    File : String, 
    Line : int, 
    CanUserDelete : boolean, 
    FlushItem : boolean
) : TaskItem

Parametri

  • Category
    Tipo: System.String
    Obbligatorio.Rappresenta il nome della categoria dell'elemento attività.
  • SubCategory
    Tipo: System.String
    Obbligatorio.Rappresenta il nome della sottocategoria dell'elemento attività.
  • Description
    Tipo: System.String
    Obbligatorio.Fornisce una descrizione dell'attività.
  • Icon
    Tipo: System.Object
    Facoltativo.Determina il tipo di icona che rappresenta la nuova attività.L'impostazione deve essere vsTaskIcon o IPictureDisp.
  • Checkable
    Tipo: System.Boolean
    Facoltativo.Indica se si desidera che venga fornita una casella di controllo che gli utenti possono selezionare per indicare che l'attività è completata.Il valore predefinito è false.
  • File
    Tipo: System.String
    Facoltativo.Indica il file o il percorso associato alla nuova attività.Il valore predefinito è una stringa vuota ("") e, se utilizzata, IsSettable(vsTaskListColumnFile) restituisce false.Il nome file può essere un percorso completo, un percorso relativo o semplicemente un nome file.L'associazione di un file o percorso a un elemento non significa necessariamente che vengano eseguite delle azioni.
  • Line
    Tipo: System.Int32
    Facoltativo.Indica la riga del codice sorgente associata alla nuova attività.Il valore predefinito è 0 e, se utilizzata, IsSettable(vsTaskListColumnLine) restituisce false.L'associazione di un numero di riga a un elemento non significa necessariamente che vengano eseguite delle azioni.
  • CanUserDelete
    Tipo: System.Boolean
    Facoltativo.Indica se un utente può eliminare la nuova attività premendo CANC quando l'elemento è selezionato nell'ambiente.Il valore predefinito è true.
  • FlushItem
    Tipo: System.Boolean
    Facoltativo.Indica se una nuova attività diventa immediatamente visibile nell'Elenco attività.Se FlushItem è impostato su true, l'Elenco attività viene aggiornato immediatamente dopo la chiamata a Add.Se FlushItem è impostato su false, l'Elenco attività viene aggiornato dopo tutti gli altri aggiornamenti.L'impostazione false viene principalmente utilizzata per migliorare le prestazioni quando si aggiungono contemporaneamente molti elementi all'Elenco attività.Il valore predefinito è true.

Valore restituito

Tipo: EnvDTE.TaskItem
Un oggetto TaskItem.

Implementa

TaskItems.Add(String, String, String, vsTaskPriority, Object, Boolean, String, Int32, Boolean, Boolean)

Note

Quando vengono aggiunte immagini bitmap, il colore RGB 0x0000FF00 (verde) è trasparente. Le parti dell'immagine che utilizzano questo valore saranno trasparenti nell'Elenco attività.

La larghezza e l'altezza delle immagini bitmap devono essere pari a 16 x 16 pixel.

Se si utilizza IPictureDisp, l'argomento PICTYPE deve essere impostato su Icon o Bitmap. Le impostazioni di Metafiles, Uninitialized o None non funzionano correttamente.

Esempi

In questo esempio vengono aggiunti due elementi all'Elenco attività e ne vengono visualizzate alcune proprietà in finestre di messaggio. Per ulteriori informazioni sulla modalità di esecuzione di questo esempio come componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

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)
    TaskItems2Example(_applicationObject)
End Sub
Sub TaskItems2Example(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)
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;
    TaskItems2Example(_applicationObject);
}
public void TaskItems2Example(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);
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

TaskItems2 Interfaccia

Overload Add

Spazio dei nomi EnvDTE80