GestureRecognizer 類別

定義

辨識墨跡。

public ref class GestureRecognizer sealed : System::Windows::DependencyObject, IDisposable
public sealed class GestureRecognizer : System.Windows.DependencyObject, IDisposable
type GestureRecognizer = class
    inherit DependencyObject
    interface IDisposable
Public NotInheritable Class GestureRecognizer
Inherits DependencyObject
Implements IDisposable
繼承
實作

範例

下列範例示範如何判斷 是否 StrokeScratchOut 手勢。

private bool InterpretScratchoutGesture(Stroke stroke)
{
    // Attempt to instantiate a recognizer for scratchout gestures.
    ApplicationGesture[] gestures = { ApplicationGesture.ScratchOut };
    GestureRecognizer recognizer = new GestureRecognizer(gestures);

    if (!recognizer.IsRecognizerAvailable)
        return false;

    // Determine if the stroke was a scratchout gesture.
    StrokeCollection gestureStrokes = new StrokeCollection();
    gestureStrokes.Add(stroke);

    ReadOnlyCollection<GestureRecognitionResult> results = recognizer.Recognize(gestureStrokes);

    if (results.Count == 0)
        return false;

    // Results are returned sorted in order strongest-to-weakest; 
    // we need only analyze the first (strongest) result.
    if (results[0].ApplicationGesture == ApplicationGesture.ScratchOut &&
          results[0].RecognitionConfidence == RecognitionConfidence.Strong)
    {
        // Use the scratchout stroke to perform hit-testing and 
        // erase existing strokes, as necessary.
        return true;
    }
    else
    {
        // Not a gesture: display the stroke normally.
        return false;
    }
}
Private Function InterpretScratchoutGesture(ByVal stroke As Stroke) As Boolean
    ' Attempt to instantiate a recognizer for scratchout gestures.
    Dim gestures() As ApplicationGesture = {ApplicationGesture.ScratchOut}

    Dim recognizer As New GestureRecognizer(gestures)

    If Not recognizer.IsRecognizerAvailable Then
        Return False
    End If

    ' Determine if the stroke was a scratchout gesture.
    Dim gestureStrokes As StrokeCollection = New StrokeCollection()
    gestureStrokes.Add(stroke)

    Dim results As ReadOnlyCollection(Of GestureRecognitionResult)
    results = recognizer.Recognize(gestureStrokes)

    If results.Count = 0 Then
        Return False
    End If

    ' Results are returned sorted in order strongest-to-weakest; 
    ' we need only analyze the first (strongest) result.
    If (results(0).ApplicationGesture = ApplicationGesture.ScratchOut) Then

        ' Use the scratchout stroke to perform hit-testing and 
        ' erase existing strokes, as necessary.
        Return True
    Else
        ' Not a gesture: display the stroke normally.
        Return False
    End If
End Function

備註

GestureRecognizer會識別筆跡手勢。 您可以設定 GestureRecognizer 來辨識應用程式手勢的所有或子集。 若要將 設定 GestureRecognizer 為辨識可用手勢的子集,請將陣列傳遞 ApplicationGesture 至建構函式或使用 SetEnabledGestures 方法。 若要判斷 是否 StrokeCollection 包含手勢,請呼叫 Recognize 方法。

XAML 文字使用方式

您無法在 XAML 中使用這個類別。

建構函式

GestureRecognizer()

初始化 GestureRecognizer 類別的新執行個體。

GestureRecognizer(IEnumerable<ApplicationGesture>)

初始化 GestureRecognizer 類別的新執行個體。

屬性

DependencyObjectType

取得包裝 DependencyObjectType 這個實例 CLR 型別的 。

(繼承來源 DependencyObject)
Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObject

(繼承來源 DispatcherObject)
IsRecognizerAvailable

取得布林 (Boolean) 值,指出使用者的系統上是否有可用的筆勢辨識器。

IsSealed

取得值,這個值表示此執行個體目前是否已密封 (唯讀)。

(繼承來源 DependencyObject)

方法

CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObject

(繼承來源 DispatcherObject)
ClearValue(DependencyProperty)

清除屬性的區域數值。 要清除的屬性是由 DependencyProperty 識別項所指定。

(繼承來源 DependencyObject)
ClearValue(DependencyPropertyKey)

清除唯讀屬性的區域數值。 要清除的屬性是由 DependencyPropertyKey 所指定。

(繼承來源 DependencyObject)
CoerceValue(DependencyProperty)

強制轉型所指定相依性屬性的值。 完成方式是叫用存在於呼叫 DependencyObject 之相依性屬性的屬性中繼資料中所指定的任何 CoerceValueCallback 函式。

(繼承來源 DependencyObject)
Dispose()

釋放 GestureRecognizer 所使用的所有資源。

Equals(Object)

判斷提供的 DependencyObject 和目前的 DependencyObject 是否相等。

(繼承來源 DependencyObject)
GetEnabledGestures()

取得 GestureRecognizer 可辨識的筆勢。

GetHashCode()

取得這個 DependencyObject 的雜湊碼。

(繼承來源 DependencyObject)
GetLocalValueEnumerator()

建立特定的列舉值,以判斷哪些相依性屬性在此 DependencyObject 上具有本機設定的值。

(繼承來源 DependencyObject)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetValue(DependencyProperty)

傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。

(繼承來源 DependencyObject)
InvalidateProperty(DependencyProperty)

重新評估指定相依性屬性的有效值。

(繼承來源 DependencyObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnPropertyChanged(DependencyPropertyChangedEventArgs)

每當這個 DependencyObject 上任何相依性屬性的有效值已更新時叫用。 已變更的特定相依性屬性會在事件資料中報告。

(繼承來源 DependencyObject)
ReadLocalValue(DependencyProperty)

傳回相依性屬性的區域值 (如果存在)。

(繼承來源 DependencyObject)
Recognize(StrokeCollection)

在指定的 StrokeCollection 中尋找筆勢。

SetCurrentValue(DependencyProperty, Object)

設定相依性屬性的值,而不需要變更其值來源。

(繼承來源 DependencyObject)
SetEnabledGestures(IEnumerable<ApplicationGesture>)

設定 GestureRecognizer 可辨識的應用程式筆勢。

SetValue(DependencyProperty, Object)

設定相依性屬性的區域值 (由相依性屬性的識別碼所指定)。

(繼承來源 DependencyObject)
SetValue(DependencyPropertyKey, Object)

設定唯讀相依性屬性的區域數值 (由相依性屬性的 DependencyPropertyKey 識別項所指定)。

(繼承來源 DependencyObject)
ShouldSerializeProperty(DependencyProperty)

傳回值,這個值表示序列化程序是否應該序列化所提供相依性屬性的值。

(繼承來源 DependencyObject)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
VerifyAccess()

請強制執行可以存取這個 DispatcherObject 的呼叫執行緒。

(繼承來源 DispatcherObject)

適用於