GestureRecognizer クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
インク ジェスチャを認識します。
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
- 継承
- 実装
例
次の例では、 Stroke が ScratchOut ジェスチャであるかどうかを判断する方法を示します。
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) |