InkEditGestureEventArgs.Gestures 属性

识别器 获取 Gesture 对象的数组(按置信度的顺序排列)。

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

语法

声明
Public ReadOnly Property Gestures As Gesture()
用法
Dim instance As InkEditGestureEventArgs
Dim value As Gesture()

value = instance.Gestures
public Gesture[] Gestures { get; }
public:
property array<Gesture^>^ Gestures {
    array<Gesture^>^ get ();
}
/** @property */
public Gesture[] get_Gestures()
public function get Gestures () : Gesture[]

属性值

类型:array<Microsoft.Ink.Gesture[]
从识别器获取的 Gesture 对象的数组(按置信度的顺序排列)。

备注

有关应用程序笔势 的说明,请参见 ApplicationGesture 枚举。

当识别器识别应用程序笔势时将发生 Gesture 事件。

该数组包含有关应用程序笔势(而不是系统笔势)的信息。有关笔势的更多信息,请参见Using Gestures

InkEdit 控件对以下笔势有默认的关注和操作。

笔势

操作

左下,长左下

Enter

向右

空格

向左

Backspace

右上、长右上

Tab

示例

此示例演示如何订阅 Gesture 事件和 Stroke 事件,以扩充 ApplicationGesture 的功能。

激发 Gesture 事件时,它会检查 InkEdit 控件的笔势和当前状态。如果有必要,将修改笔势的行为,并取消该事件。

Private Sub mInkEdit_Gesture(ByVal sender As Object, ByVal e As InkEditGestureEventArgs)
    ' There might be more than one gesture passed in InkEditGestureEventArgs
    ' The gestures are arranged in order of confidence from most to least
    ' This event handler is only concerned with the first (most confident) gesture
    ' and only if the gesture is ApplicationGesture.Left with strong confidence
    Dim G As Gesture = e.Gestures(0)
    If (ApplicationGesture.Left = G.Id And RecognitionConfidence.Strong = G.Confidence) Then
        Dim pInkEdit As InkEdit = DirectCast(sender, InkEdit)
        ' by default, ApplicationGesture.Left maps to Backspace
        ' If the insertion point is at the beginning of the text
        ' and there is no text selected, then Backspace does not do anything.
        ' In this case, we will alter the gesture to map to Delete instead
        If (0 = pInkEdit.SelectionStart And 0 = pInkEdit.SelectionLength And pInkEdit.Text.Length > 0) Then
            ' take out the first character of the string
            pInkEdit.Text = pInkEdit.Text.Remove(0, 1)
            ' save the stroke ID in a class level var for use in the Stroke event
            Me.mStrokeID = e.Strokes(0).Id
            ' cancel the gesture so it won't perform the default action
            e.Cancel = True
        End If
    End If
End Sub
private void mInkEdit_Gesture(object sender, InkEditGestureEventArgs e)
{
    // There might be more than one gesture passed in InkEditGestureEventArgs
    // The gestures are arranged in order of confidence from most to least
    // This event handler is only concerned with the first (most confident) gesture
    // and only if the gesture is ApplicationGesture.Left with strong confidence
    Gesture G = e.Gestures[0];
    if (ApplicationGesture.Left == G.Id &&  RecognitionConfidence.Strong == G.Confidence)
    {
        InkEdit pInkEdit = (InkEdit)sender;

        // by default, ApplicationGesture.Left maps to Backspace
        // If the insertion point is at the beginning of the text
        // and there is no text selected, then Backspace does not do anything.
        // In this case, we will alter the gesture to map to Delete instead
        if (0 == pInkEdit.SelectionStart && 0 == pInkEdit.SelectionLength && pInkEdit.Text.Length > 0)
        {
            // take out the first character of the string
            pInkEdit.Text = pInkEdit.Text.Remove(0, 1);
            // save the stroke ID in a class level var for use in the Stroke event
            this.mStrokeID = e.Strokes[0].Id;
            // cancel the gesture so it won't perform the default action
            e.Cancel = true;
        }
    }
}

激发 Stroke 事件时,如果笔画是用于生成已在 Gesture 事件中修改其行为的笔势的那个笔画,则取消该事件。这将使笔画无法呈现。

Private Sub mInkEdit_Stroke(ByVal sender As Object, ByVal e As InkEditStrokeEventArgs)
    e.Cancel = (e.Stroke.Id = Me.mStrokeID)
End Sub
private void mInkEdit_Stroke(object sender, InkEditStrokeEventArgs e)
{
    e.Cancel = (e.Stroke.Id == this.mStrokeID);
}

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkEditGestureEventArgs 类

InkEditGestureEventArgs 成员

Microsoft.Ink 命名空间

Gesture

Gesture.Id

InkEdit

InkEdit.Gesture