GestureRecognizer.IsRecognizerAvailable プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ユーザーのシステムでジェスチャ レコグナイザーを使用できるかどうかを示すブール値を取得します。
public:
property bool IsRecognizerAvailable { bool get(); };
public bool IsRecognizerAvailable { get; }
member this.IsRecognizerAvailable : bool
Public ReadOnly Property IsRecognizerAvailable As Boolean
プロパティ値
認識コンポーネントを使用できる場合は true
。それ以外の場合は false
。
例
次の例では、メソッドを呼び出す前にジェスチャ認識エンジンを使用できるかどうかを確認する方法を Recognize 示します。
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