Condividi tramite


Evento Strokes.StrokesAdded

Aggiornamento: novembre 2007

Si verifica quando uno o più oggetti Stroke vengono aggiunti all'insieme Strokes.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Sintassi

'Dichiarazione
Public Event StrokesAdded As StrokesEventHandler
'Utilizzo
Dim instance As Strokes
Dim handler As StrokesEventHandler

AddHandler instance.StrokesAdded, handler
public event StrokesEventHandler StrokesAdded
public:
 event StrokesEventHandler^ StrokesAdded {
    void add (StrokesEventHandler^ value);
    void remove (StrokesEventHandler^ value);
}
/** @event */
public void add_StrokesAdded (StrokesEventHandler value)
/** @event */
public void remove_StrokesAdded (StrokesEventHandler value)
JScript non supporta gli eventi.

Note

Il gestore eventi riceve un argomento di tipo StrokesEventArgs contenente i dati relativi a questo evento.

Quando si crea un delegato StrokesEventHandler, viene identificato il metodo che gestisce l'evento. Per associare l'evento al gestore in uso, aggiungere all'evento un'istanza del delegato. Il gestore eventi viene chiamato ogni volta che si verifica l'evento, a meno che non si rimuova il delegato.

Esempi

In questo esempio, un gestore eventi StrokesAdded ruota di 90 gradi in senso orario i tratti appena aggiunti. La rotazione viene eseguita attorno al centro del riquadro dell'oggetto Stroke appena aggiunto.

' Reminder: To avoid a memory leak, you must explicitly call the Dispose() method 
' on any Strokes collection to which an event handler has been attached before 
' the collection goes out of scope. 
Private Sub Strokes_StrokesAdded(ByVal sender As Object, ByVal e As StrokesEventArgs)
    ' check each stroke id passed to the handler
    For Each id As Integer In e.StrokeIds
        ' find the Stroke
        For Each oneStroke As Stroke In DirectCast(sender, Strokes)
            ' when we find the added stroke, rotate it 
            If (oneStroke.Id = id) Then
                Dim bounds As Rectangle = oneStroke.GetBoundingBox()
                ' create a point at the center of bounding box
                Dim center As Point = New Point(bounds.Left + (bounds.Width / 2), bounds.Top + (bounds.Height / 2))
                ' rotate the stroke
                oneStroke.Rotate(90, center)
            End If
        Next
    Next
End Sub
// Reminder: To avoid a memory leak, you must explicitly call the Dispose() method 
// on any Strokes collection to which an event handler has been attached before 
// the collection goes out of scope. 
private void Strokes_StrokesAdded(object sender, StrokesEventArgs e)
{
    // check each stroke id passed to the handler
    foreach (int id in e.StrokeIds)
    {
        // find the Stroke
        foreach (Stroke oneStroke in (Strokes)sender)
        {
            // when we find the added stroke, rotate it 
            if (oneStroke.Id == id)
            {
                Rectangle bounds = oneStroke.GetBoundingBox();
                // create a point at the center of bounding box
                Point center = new Point(bounds.Left + (bounds.Width / 2), bounds.Top + (bounds.Height / 2));
                // rotate the stroke
                oneStroke.Rotate(90, center);
            }
        }
    }

}

Piattaforme

Windows Vista

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

Strokes Classe

Membri Strokes

Spazio dei nomi Microsoft.Ink

Ink

Strokes.Add