InkPicture.Gesture 事件

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

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

语法

声明
Public Event Gesture As InkCollectorGestureEventHandler
用法
Dim instance As InkPicture
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 不支持事件。

备注

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

有关特定应用程序笔势的列表,请参见 ApplicationGesture 枚举类型。有关应用程序笔势的更多信息,请参见Using GesturesCommand Input on the Tablet PC

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

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

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

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

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

除了在插入墨迹时激发之外,在应用 InkOverlayEditingMode 枚举值 SelectDelete 时也会激发 Gesture 事件。您要负责跟踪编辑模式,并且应当在解释事件之前注意模式。

备注

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

备注

InkPicture 控件使用 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;
        }
    }

}

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

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

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

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

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkPicture 类

InkPicture 成员

Microsoft.Ink 命名空间

ApplicationGesture

InkCollectorGestureEventArgs

InkOverlayEditingMode

InkPicture.SetGestureStatus