Freigeben über


Ink.InkDeleted Event

Ink.InkDeleted Event

Occurs when a stroke is deleted from the Ink object.

Definition

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

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 InkDeleted event is fired even when in select mode, not just when in delete mode. 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 InkDeleted event handler to an Ink object. The event handler writes information about the deleted strokes to a list box named listBox1.

//...

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

//...

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

[Visual Basic .NET]

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

'...

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

'...

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

See Also