다음을 통해 공유


Ink.InkAdded Event

Occurs when a Stroke object is added to the Ink object.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Event InkAdded As StrokesEventHandler
'Usage
Dim instance As Ink
Dim handler As StrokesEventHandler

AddHandler instance.InkAdded, handler
public event StrokesEventHandler InkAdded
public:
event StrokesEventHandler^ InkAdded {
    void add (StrokesEventHandler^ value);
    void remove (StrokesEventHandler^ value);
}
/** @event */
public void add_InkAdded (StrokesEventHandler value)

/** @event */
public void remove_InkAdded (StrokesEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

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 handles 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, the following sequence of events occurs:

  1. InkDeleted

  2. InkAdded

  3. InkDeleted

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

The InkAdded event fires even when in select or erase mode, not only 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.

Example

This C# example adds an InkAdded event handler to an Ink object. The event handler writes information about the added strokes to a list box, theListBox.

//...

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

//...

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

This Microsoft Visual Basic.NET example adds an InkAdded event handler to an Ink object. The event handler writes information about the added strokes to a list box, theListBox.

 '...

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
    theListBox.Items.Clear()
    Dim i As Integer
    For Each i In theAddedStrokeIds
        theListBox.Items.Add("Added Stroke Id: " & i.ToString())
    Next
End Sub

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Ink Class
Ink Members
Microsoft.Ink Namespace
Ink.InkDeleted
InkOverlay.EditingMode
InkOverlay.EraserMode
InkPicture.EditingMode
InkPicture.EraserMode
InkCollector.Stroke
InkOverlay.Stroke
InkPicture.Stroke
Stroke