Share via


InkCollectorCursorDownEventHandler Delegate

InkCollectorCursorDownEventHandler Delegate

Represents the method that handles the CursorDown event of an InkCollector.

Definition

Visual Basic .NET Public Delegate Sub InkCollectorCursorDownEventHandler( _
ByVal sender As Object, _
ByVal e As InkCollectorCursorDownEventArgs _
)
C# public delegate void InkCollectorCursorDownEventHandler(
object sender,
InkCollectorCursorDownEventArgs e
);
Managed C++ public: __gc __delegate void InkCollectorCursorDownEventHandler(
Object *sender,
InkCollectorCursorDownEventArgs *e
);

Parameters

sender System.Object. [in] Specifies the source InkCollector of this event.
e Microsoft.Ink.InkCollectorCursorDownEventArgs. [in] Specifies the InkCollectorCursorDownEventArgs object that contains the event data.

Delegate Information

Namespace Microsoft.Ink
Assembly Microsoft.Ink (microsoft.ink.dll)
Strong Name Microsoft.Ink, Version=1.7.4009.0, Culture=neutral, PublicKeyToken=a2870d9cc4d021c8

Remarks

When you create an InkCollectorCursorDownEventHandler 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. For performance reasons, the default event interest is off but is turned on automatically in managed code if you add an event handler.

Use this event carefully because it could have an adverse effect on ink performance if too much code is executed in the event handlers. To improve real-time ink performance, hide or show the mouse cursor in the MouseDown and MouseUp event handlers.

Examples

[C#]

This C# example demonstrates using several event handlers to display the state of the cursors, cursor buttons, and tablets. This simple application has a status bar with three panels (sbPanelCursor, sbPanelButton, and sbPanelTablet), where simple messages appear when events are received.

//...
using Microsoft.Ink;
//...
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.StatusBar statusBar1;
        private System.Windows.Forms.StatusBarPanel sbPanelCursor;
        private System.Windows.Forms.StatusBarPanel sbPanelButton;
        private System.Windows.Forms.StatusBarPanel sbPanelTablet;
        InkCollector theInkCollector;
//...

        public Form1()
        {
            //...

            // Initialize the InkCollector with this form's
            // window handle.
            theInkCollector = new InkCollector(Handle);
            theInkCollector.Enabled = true;

            // Add event handlers for cursor and button events.
            theInkCollector.CursorButtonUp += new InkCollectorCursorButtonUpEventHandler(CursorButtonUp_Event);
            theInkCollector.CursorButtonDown += new InkCollectorCursorButtonDownEventHandler(CursorButtonDown_Event);
            theInkCollector.CursorOutOfRange += new InkCollectorCursorOutOfRangeEventHandler(CursorOutOfRange_Event);
            theInkCollector.CursorInRange += new InkCollectorCursorInRangeEventHandler(CursorInRange_Event);
            theInkCollector.CursorDown += new InkCollectorCursorDownEventHandler(CursorDown_Event);
            theInkCollector.TabletAdded += new InkCollectorTabletAddedEventHandler(TabletAdded_Event);
            theInkCollector.TabletRemoved += new InkCollectorTabletRemovedEventHandler(TabletRemoved_Event);
        }

//...

        private void CursorButtonUp_Event(object sender, InkCollectorCursorButtonUpEventArgs e)
        {
            sbPanelButton.Text = e.Button.Name + " Button Up";
        }

        private void CursorButtonDown_Event(object sender, InkCollectorCursorButtonDownEventArgs e)
        {
            sbPanelButton.Text = e.Button.Name + " Button Down";
        }

        private void CursorOutOfRange_Event(object sender, InkCollectorCursorOutOfRangeEventArgs e)
        {
            sbPanelCursor.Text = e.Cursor.Name + " Out of Range";
        }

        private void CursorInRange_Event(object sender, InkCollectorCursorInRangeEventArgs e)
        {
            sbPanelCursor.Text = e.Cursor.Name + " In Range";
        }

        private void CursorDown_Event(object sender, InkCollectorCursorDownEventArgs e)
        {
            sbPanelCursor.Text = e.Cursor.Name + " Down";
        }

        private void TabletAdded_Event(object sender, InkCollectorTabletAddedEventArgs e)
        {
            sbPanelTablet.Text = "Tablet added: " + e.Tablet.Name;
        }

        private void TabletRemoved_Event(object sender, InkCollectorTabletRemovedEventArgs e)
        {
            sbPanelTablet.Text = "Tablet removed: " + e.TabletId;
        }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example demonstrates using several event handlers to display the state of the cursors, cursor buttons, and tablets. This simple application has a status bar with three panels (sbPanelCursor, sbPanelButton, and sbPanelTablet), where simple messages appear when events are received.

Imports Microsoft.Ink
Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim theInkCollector As InkCollector

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        theInkCollector = New InkCollector(Handle)
        theInkCollector.Enabled = True
        AddHandler theInkCollector.CursorButtonUp, AddressOf CursorButtonUp_Event
        AddHandler theInkCollector.CursorButtonDown, AddressOf CursorButtonDown_Event
        AddHandler theInkCollector.CursorOutOfRange, AddressOf CursorOutOfRange_Event
        AddHandler theInkCollector.CursorInRange, AddressOf CursorInRange_Event
        AddHandler theInkCollector.CursorDown, AddressOf CursorDown_Event
        AddHandler theInkCollector.TabletAdded, AddressOf TabletAdded_Event
        AddHandler theInkCollector.TabletRemoved, AddressOf TabletRemoved_Event

    End Sub

'...

#End Region

    Private Sub CursorButtonUp_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorButtonUpEventArgs)
        sbPanelButton.Text = e.Button.Name + " Button Up"
    End Sub

    Private Sub CursorButtonDown_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorButtonDownEventArgs)
        sbPanelButton.Text = e.Button.Name + " Button Down"
    End Sub

    Private Sub CursorOutOfRange_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorOutOfRangeEventArgs)
        sbPanelCursor.Text = e.Cursor.Name + " Out of Range"
    End Sub

    Private Sub CursorInRange_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorInRangeEventArgs)
        sbPanelCursor.Text = e.Cursor.Name + " In Range"
    End Sub

    Private Sub CursorDown_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorDownEventArgs)
        sbPanelCursor.Text = e.Cursor.Name + " Down"
    End Sub

    Private Sub TabletAdded_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorTabletAddedEventArgs)
        sbPanelTablet.Text = "Tablet Added: " + e.Tablet.Name
    End Sub

    Private Sub TabletRemoved_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorTabletRemovedEventArgs)
        sbPanelTablet.Text = "Tablet Removed: " + e.TabletId
    End Sub

End Class

See Also