Gesture.HotPoint Property

Gesture.HotPoint Property

Gets the hot point of the gesture, in ink space coordinates.

Definition

Visual Basic .NET Public ReadOnly Property HotPoint As Point
C# public Point HotPoint { get; }
Managed C++ public: __property Point* get_HotPoint();

Property Value

System.Drawing.Point. The hot point of the gesture, in ink space coordinates.

This property is read-only. This property has no default value.

Remarks

The hot point is the one distinguishing point of a gesture. It is usually the point of the angle in a gesture or the point at which the gesture is intended to occur in relation to the content around it. If thee is no discernable hot point for a known gesture, the starting point of the gesture is the hot point.

For example, the hot point of the Check gesture is the point of the angle, and the hot point of the Curlicue gesture is the start of the stroke that is the gesture.

For more information about how a hot point is used, see Making Windows Work with a Pen.

Examples

[C#]

This C# example reports gesture information in a status bar, theGestureStatusBar, and draws a small circle around the hot point location, theHotPoint.

using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Ink;

public class CSGestureForm : System.Windows.Forms.Form
{
    private System.Windows.Forms.StatusBar theGestureStatusBar;
    private InkCollector theInkCollector;
    private Point theHotPoint;

    public CSGestureForm()
    {
        // Initialize the form with a status bar at the bottom.
        theGestureStatusBar = new System.Windows.Forms.StatusBar();
        SuspendLayout();
        theGestureStatusBar.Location = new System.Drawing.Point(0, 244);
        theGestureStatusBar.Size = new System.Drawing.Size(300, 22);
        theGestureStatusBar.Text = "";
        ClientSize = new System.Drawing.Size(300, 266);
        Controls.AddRange(new System.Windows.Forms.Control[] {this. theGestureStatusBar });
        Text = "Gesture Test Application";
        Paint += new System.Windows.Forms.PaintEventHandler(this.CSGestureForm_Paint);
        this.BackColor = Color.LightGray;
        ResumeLayout(false);

        // Give the hot spot an initial value.
        theHotPoint = new Point(-1, -1);

        // Initialize the InkCollector object.
        theInkCollector = new InkCollector(Handle);
        theInkCollector.CollectionMode = CollectionMode.GestureOnly;
        theInkCollector.SetGestureStatus(ApplicationGesture.Check, true);
        theInkCollector.Gesture += new InkCollectorGestureEventHandler(Gesture_Event);
        theInkCollector.Enabled = true;
    }

    static void Main()
    {
        Application.Run(new CSGestureForm());
    }

    private void Gesture_Event(object sender, InkCollectorGestureEventArgs e)
    {
        // Only get information on the first gesture returned.
        Gesture theGesture = e.Gestures[0];
        // Save the hot point information for painting.
        theHotPoint = theGesture.HotPoint;
        // Write the gesture type and confidence on the status bar.
        theGestureStatusBar.Text = theGesture.Id +"  "+ theGesture.Confidence;
        Refresh();
    }

    private void CSGestureForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        // Transform hotspot from HIMETRIC to window coordinates.
        theInkControl.Renderer.InkSpaceToPixel(g, ref theHotPoint);
        // Draw a little circle around the hotspot.
        g.DrawEllipse(Pens.Orange, theHotPoint.X-4, theHotPoint.Y-4, 9, 9);
        g.Dispose();
    }

        // Event handler for the form's closed event
        private void CSGestureForm_Closed(object sender, System.EventArgs e)
        {
            theInkCollector.Dispose();
            theInkCollector = null;
        }
}
                

[VB.NET]

This Microsoft® Visual Basic® .NET example reports gesture information in a status bar, theStatusBar, and draws a small circle around the hot point location, theHotPoint.

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

#Region " Windows Form Designer generated code "
'This contains the default form code, plus a status bar, theStatusBar.
#End Region

    Dim theInkCollector As InkCollector
    Dim theHotPoint As System.Drawing.Point

    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        theHotPoint = New Point(-1, -1)
        theInkCollector = New InkCollector(Handle)
        theInkCollector.CollectionMode = CollectionMode.GestureOnly
        theInkCollector.SetGestureStatus(ApplicationGesture.Check, True)
        AddHandler theInkCollector.Gesture, AddressOf Gesture_Event
        theInkCollector.Enabled = True
    End Sub

    Private Sub Gesture_Event( _
    ByVal sender As Object, _
    ByVal e As InkCollectorGestureEventArgs)
        'Only get information on the first gesture returned.
        Dim theGesture As Gesture = e.Gestures(0)
        'Save the hot point information for painting.
        theHotPoint = theGesture.HotPoint
        'Write the gesture type and confidence on the status bar.
        theStatusBar.Text = theGesture.Id.ToString() & _
        "  " & theGesture.Confidence.ToString()
        Refresh()
    End Sub

    Private Sub Form1_Paint( _
    ByVal sender As Object, _
    ByVal e As System.Windows.Forms.PaintEventArgs) _
    Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        'Convert from ink to window coordinates and draw a circle.
        theInkCollector.Renderer.InkSpaceToPixel(g, theHotPoint)
        g.DrawEllipse(Pens.Red, theHotPoint.X - 4, theHotPoint.Y - 4, 9, 9)
    End Sub

    'Event handler for the form's closed event
    Private Sub Form1_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        theInkCollector.Dispose()
        Set theInkCollector = Nothing
    End Sub
End Class
                

See Also