Condividi tramite


Metodo TaskItems2.Add2

Aggiunge una nuova attività all'oggetto TaskList.

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

Sintassi

'Dichiarazione
Function Add2 ( _
    Category As String, _
    SubCategory As String, _
    Description As String, _
    Priority As Integer, _
    Icon As Object, _
    Checkable As Boolean, _
    File As String, _
    Line As Integer, _
    CanUserDelete As Boolean, _
    FlushItem As Boolean, _
    AutoNavigate As Boolean _
) As TaskItem
TaskItem Add2(
    string Category,
    string SubCategory,
    string Description,
    int Priority,
    Object Icon,
    bool Checkable,
    string File,
    int Line,
    bool CanUserDelete,
    bool FlushItem,
    bool AutoNavigate
)
TaskItem^ Add2(
    [InAttribute] String^ Category, 
    [InAttribute] String^ SubCategory, 
    [InAttribute] String^ Description, 
    [InAttribute] int Priority, 
    [InAttribute] Object^ Icon, 
    [InAttribute] bool Checkable, 
    [InAttribute] String^ File, 
    [InAttribute] int Line, 
    [InAttribute] bool CanUserDelete, 
    [InAttribute] bool FlushItem, 
    [InAttribute] bool AutoNavigate
)
abstract Add2 : 
        Category:string * 
        SubCategory:string * 
        Description:string * 
        Priority:int * 
        Icon:Object * 
        Checkable:bool * 
        File:string * 
        Line:int * 
        CanUserDelete:bool * 
        FlushItem:bool * 
        AutoNavigate:bool -> TaskItem 
function Add2(
    Category : String, 
    SubCategory : String, 
    Description : String, 
    Priority : int, 
    Icon : Object, 
    Checkable : boolean, 
    File : String, 
    Line : int, 
    CanUserDelete : boolean, 
    FlushItem : boolean, 
    AutoNavigate : 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à.
  • Priority
    Tipo: System.Int32
    Facoltativo.Costante vsTaskPriority che indica la priorità dell'attività: alta, media o bassa.Se il valore è vsTaskPriorityHigh, l'icona di un punto esclamativo viene visualizzata nella prima colonna dell'Elenco attività.Se il valore è vsTaskPriorityMedium, non viene visualizzato nulla.Se il valore è vsTaskPriorityLow, viene visualizzata l'icona di una freccia verso il basso.
  • 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.
  • AutoNavigate
    Tipo: System.Boolean
    Facoltativo.Indica se per l'oggetto TaskItem è attivata la funzionalità AutoNavigate.La funzionalità è attivata quando è impostata su true; in caso contrario false.

Valore restituito

Tipo: EnvDTE.TaskItem
Un oggetto TaskItem.

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à mediante il metodo Add2 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)
    TaskItemsAdd2Example(_applicationObject)
End Sub
Sub TaskItemsAdd2Example(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 using Add2.
    TLItem = TLItems.Add2(" ", " ", "Test task 1." _
    , vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser _
    , True, , 10, , , False)
        TLItem = TLItems.Add2(" ", " ", "Test task 2." _
    , vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment _
    , , , 20, , , False)
    ' 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;
    TaskItems2Add2Example(_applicationObject);
}
public void TaskItems2Add2Example(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.Add2("MyTask", "MyTask1", "Test task 1."
, 1, vsTaskIcon.vsTaskIconUser, true,null,10,true,true,true);
TLItem = TLItems.Add2("MyTask", "MyTask1", "Test task 2."
, 2, vsTaskIcon.vsTaskIconComment, true, null, 20, true, true,false);
    // 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

Spazio dei nomi EnvDTE80