Поделиться через


Strokes.StrokesAdded - событие

Обновлен: Ноябрь 2007

Occurs when one or more Stroke objects are added to the Strokes collection.

Пространство имен:  Microsoft.Ink
Сборка:  Microsoft.Ink (в Microsoft.Ink.dll)

Синтаксис

'Декларация
Public Event StrokesAdded As StrokesEventHandler
'Применение
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 не поддерживает события.

Заметки

The event handler receives an argument of type StrokesEventArgs containing data about this event.

When you create a StrokesEventHandler delegate, you identify the method handling the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

Примеры

In this example, a StrokesAdded event handler rotates newly added strokes clockwise 90 degrees. The rotation occurs around the center of the bounding box of the newly added Stroke object.

' 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);
            }
        }
    }

}

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

Strokes Класс

Strokes - члены

Microsoft.Ink - пространство имен

Ink

Strokes.Add