共用方式為


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

向右

空格鍵

向左

退格鍵

向右上、向右上拉長

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