InkCollector.Gesture 事件

识别应用程序笔势 时发生。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Event Gesture As InkCollectorGestureEventHandler
用法
Dim instance As InkCollector
Dim handler As InkCollectorGestureEventHandler

AddHandler instance.Gesture, handler
public event InkCollectorGestureEventHandler Gesture
public:
 event InkCollectorGestureEventHandler^ Gesture {
    void add (InkCollectorGestureEventHandler^ value);
    void remove (InkCollectorGestureEventHandler^ value);
}
/** @event */
public void add_Gesture (InkCollectorGestureEventHandler value)
/** @event */
public void remove_Gesture (InkCollectorGestureEventHandler value)
JScript 不支持事件。

备注

若要让此事件发生,InkCollector 对象必须设置对一组应用程序笔势的关注。若要设置 InkCollector 对象对一组笔势的关注,请调用 SetGestureStatus 方法。

有关特定应用程序笔势的列表,请参见 ApplicationGesture 枚举。有关应用程序笔势的更多信息,请参见Pen Input, Ink, and Recognition

事件处理程序接收 InkCollectorGestureEventArgs 类型的参数,该参数包含有关此事件的数据。

创建 InkCollectorGestureEventHandler 委托时,需要标识将处理该事件的方法。若要将该事件与事件处理程序关联,请将该委托的一个实例添加到事件中。除非移除了该委托,否则每当发生该事件时就会调用此事件处理程序。

如果 CollectionMode 属性设置为 GestureOnly,则从用户添加笔势到 Gesture 事件发生之间的超时是一个固定值,无法以编程方式更改。在 InkAndGesture 模式中,笔势识别的速度更快。

若要在 InkAndGesture 模式中禁止收集墨迹:

请将 CollectionMode 设置为 InkAndGesture

  • Stroke 事件中删除 Stroke 对象。

  • 在 Gesture 事件中处理笔势。

若要在笔势处理时禁止墨迹流,请将 DynamicRendering 属性设置为 false。

除了在用户插入墨迹时以外,当 InkCollector 对象处于选择或擦除模式时,也会激发 Gesture 事件。您要负责跟踪编辑模式,并且应当在解释事件之前注意模式。

备注

若要识别笔势,必须使用可以收集墨迹的对象或控件。

备注

InkCollector 对象使用 InkCollectorGestureEventHandler 委托来添加笔势事件处理程序。

示例

此示例中的事件处理程序在状态栏标签 statusLabelAppGesture 上显示应用程序笔势信息。

Private Sub Event_OnApplicationGesture(ByVal sender As Object, ByVal e As InkCollectorGestureEventArgs)

    ' There might be more than one gesture passed in InkCollectorGestureEventArgs
    ' The gestures are arranged in order of confidence from most to least
    ' This event handler is only concerned with the first (most confident) gesture
    Dim G As Gesture = e.Gestures(0)

    ' we will use the gesture if it has confidence of strong or intermediate

    If G.Confidence = RecognitionConfidence.Intermediate Or _
    G.Confidence = RecognitionConfidence.Strong Then

        Select Case G.Id
            Case ApplicationGesture.Left
                statusLabelAppGesture.Text = "Left"
            Case ApplicationGesture.Right
                statusLabelAppGesture.Text = "Right"
            Case ApplicationGesture.Up
                statusLabelAppGesture.Text = "Up"
            Case ApplicationGesture.Down
                statusLabelAppGesture.Text = "Down"
        End Select

    End If
End Sub
void Event_OnApplicationGesture(object sender, InkCollectorGestureEventArgs e)
{
    // There might be more than one gesture passed in InkCollectorGestureEventArgs
    // The gestures are arranged in order of confidence from most to least
    // This event handler is only concerned with the first (most confident) gesture
    Gesture G = e.Gestures[0];

    // we will use the gesture if it has confidence of strong or intermediate

    if (G.Confidence == RecognitionConfidence.Intermediate ||
        G.Confidence == RecognitionConfidence.Strong)
    {

        switch (G.Id)
        {
            case ApplicationGesture.Left:
                statusLabelAppGesture.Text = "Left";
                break;
            case ApplicationGesture.Right:
                statusLabelAppGesture.Text = "Right";
                break;
            case ApplicationGesture.Up:
                statusLabelAppGesture.Text = "Up";
                break;
            case ApplicationGesture.Down:
                statusLabelAppGesture.Text = "Down";
                break;
        }
    }

}

只有已设置为关注的应用程序笔势才会激发此事件。在此示例中,InkCollector 对象 mInkCollector 设置对 ApplicationGesture 枚举的四个笔势的关注。

' set InkCollector interest in the Left, Right, Up, Down gestures
mInkCollector.SetGestureStatus(ApplicationGesture.Left, True)
mInkCollector.SetGestureStatus(ApplicationGesture.Right, True)
mInkCollector.SetGestureStatus(ApplicationGesture.Up, True)
mInkCollector.SetGestureStatus(ApplicationGesture.Down, True)
// set InkCollector interest in the Left, Right, Up, Down gestures
mInkCollector.SetGestureStatus(ApplicationGesture.Left, true);
mInkCollector.SetGestureStatus(ApplicationGesture.Right, true);
mInkCollector.SetGestureStatus(ApplicationGesture.Up, true);
mInkCollector.SetGestureStatus(ApplicationGesture.Down, true);

在收集墨迹和笔势之前,InkCollector 对象 mInkCollector 注册事件处理程序。

' register the Gesture event handler
AddHandler mInkCollector.Gesture, New InkCollectorGestureEventHandler(AddressOf Event_OnApplicationGesture)
// register the Gesture event handler
mInkCollector.Gesture += new InkCollectorGestureEventHandler(Event_OnApplicationGesture);

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkCollector 类

InkCollector 成员

Microsoft.Ink 命名空间

InkCollectorGestureEventArgs

ApplicationGesture

InkCollector.SetGestureStatus