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

このインスタンスの CLR 型をラップする DependencyObjectType を取得します。

(継承元 DependencyObject)
Dispatcher

このDispatcherが関連付けられているDispatcherObjectを取得します。

(継承元 DispatcherObject)
IsRecognizerAvailable

ジェスチャ認識エンジンがユーザーのシステムで使用できるかどうかを示すブール値を取得します。

IsSealed

このインスタンスが現在シールされているかどうかを示す値を取得します (読み取り専用)。

(継承元 DependencyObject)

メソッド

名前 説明
CheckAccess()

呼び出し元のスレッドがこの DispatcherObjectにアクセスできるかどうかを判断します。

(継承元 DispatcherObject)
ClearValue(DependencyProperty)

プロパティのローカル値をクリアします。 クリアするプロパティは、 DependencyProperty 識別子によって指定されます。

(継承元 DependencyObject)
ClearValue(DependencyPropertyKey)

読み取り専用プロパティのローカル値をクリアします。 クリアするプロパティは、 DependencyPropertyKeyによって指定されます。

(継承元 DependencyObject)
CoerceValue(DependencyProperty)

指定した依存関係プロパティの値を強制します。 これは、呼び出し元のCoerceValueCallbackに存在する依存関係プロパティのプロパティ メタデータで指定されたDependencyObject関数を呼び出すことによって実現されます。

(継承元 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)

適用対象