Compartir a través de


Ink.InkAdded Event

Ink.InkAdded Event

Occurs when a stroke is added to the Ink object.

Definition

Visual Basic .NET Public Event InkAdded As StrokesEventHandler
C# public event StrokesEventHandler InkAdded;
Managed C++ public: __event StrokesEventHandler InkAdded;

Remarks

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

When you create a StrokesEventHandler delegate, you identify the method that will handle 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.

If you use the InkOverlay object or the InkPicture control (where EditingMode equals Delete and EraserMode equals StrokeErase) and pass the eraser over a stroke, you get the following sequence of events:

The additional InkAdded and InkDeleted events occur because the underlying code adds an internal, invisible stroke to track the eraser.

The InkAdded event is fired even when in select or erase mode, not just when inserting ink. This requires that you monitor the editing mode (which you are responsible for setting) and be aware of the mode before interpreting the event. The advantage of this requirement is greater freedom to innovate on the platform through greater awareness of platform events.

Examples

[C#]

This C# example demonstrates adding an InkAdded event handler to an Ink object. The event handler writes information about the added strokes to a list box named listBox1.

//...

InkCollector theInkCollector = new InkCollector(Handle);
theInkCollector.Enabled = true;
// Add a handler for InkAdded Events to display
// their Ids in a listbox.
theInkCollector.Ink.InkAdded += new StrokesEventHandler(InkAdded_Event);

//...

public void InkAdded_Event(object sender, StrokesEventArgs e)
{
    int [] theAddedStrokeIds = e.StrokeIds;
    listBox1.Items.Clear();
    foreach (int i in theAddedStrokeIds)
    {
        listBox1.Items.Add("Added Stroke Id: " + i.ToString());
    }
}

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example example demonstrates adding an InkAdded event handler to an Ink object. The event handler writes information about the added strokes to a list box named ListBox1.

'...

Dim theInkCollector As New InkCollector(Handle)
theInkCollector.Enabled = true
'Add a handler for InkAdded Events to display
'their Ids in a listbox.
AddHandler theInkCollector.Ink.InkAdded, AddressOf InkAdded_Event

'...

Public Sub InkAdded_Event(ByVal sender as Object, _
    ByVal e As StrokesEventArgs)
    Dim theAddedStrokeIds() As Integer = e.StrokeIds
    ListBox1.Items.Clear()
    Dim i As Integer
    For Each i In theAddedStrokeIds
        ListBox1.Items.Add("Added Stroke Id: " & i.ToString())
    Next
End Sub

See Also