Freigeben über


Gesture.HotPoint Property

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

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

Syntax

'Declaration
Public ReadOnly Property HotPoint As Point
'Usage
Dim instance As Gesture
Dim value As Point

value = instance.HotPoint
public Point HotPoint { get; }
public:
property Point HotPoint {
    Point get ();
}
/** @property */
public Point get_HotPoint ()
public function get HotPoint () : Point
Not applicable.

Property Value

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

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, in the ApplicationGesture enumeration, is the start of the stroke that is the gesture.

For more information about how a hot point is used, see Using Gestures.

Example

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;
        }
}

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

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

Gesture Class
Gesture Members
Microsoft.Ink Namespace
ApplicationGesture
SystemGesture