RecognizerContextRecognitionEventArgs.RecognitionStatus 屬性
取得 RecognitionStatus 列舉值,這個值表示以最近辨識結果為準的辨識狀態。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public ReadOnly Property RecognitionStatus As RecognitionStatus
'用途
Dim instance As RecognizerContextRecognitionEventArgs
Dim value As RecognitionStatus
value = instance.RecognitionStatus
public RecognitionStatus RecognitionStatus { get; }
public:
property RecognitionStatus RecognitionStatus {
RecognitionStatus get ();
}
/** @property */
public RecognitionStatus get_RecognitionStatus()
public function get RecognitionStatus () : RecognitionStatus
屬性值
型別:Microsoft.Ink.RecognitionStatus
以最近辨識結果為準的辨識狀態。
範例
在這個範例中,會自動辨識 InkOverlay 物件中所建立的每個筆劃,並顯示辨識結果。
當 Stroke 事件引發時 (回應完成筆劃的使用者),剛建立的筆劃會加入至 RecognizerContext 物件的 Strokes 集合,並且會呼叫 BackgroundRecognize 方法,將目前時間傳遞至 customData 參數。
Private Sub mInkOverlay_Stroke4(ByVal sender As Object, ByVal e As InkCollectorStrokeEventArgs)
' in case background recognition is still occurring, stop it
mRecognizerContext.StopBackgroundRecognition()
' add the stroke, and start recognition
mRecognizerContext.Strokes.Add(e.Stroke)
mRecognizerContext.BackgroundRecognize(DateTime.Now)
End Sub
private void mInkOverlay_Stroke4(object sender, InkCollectorStrokeEventArgs e)
{
// in case background recognition is still occurring, stop it
mRecognizerContext.StopBackgroundRecognition();
// add the stroke, and start recognition, passing current time
mRecognizerContext.Strokes.Add(e.Stroke);
mRecognizerContext.BackgroundRecognize(DateTime.Now);
}
背景辨識完成時,會引發 Recognition 事件。在處理這個事件期間,辨識的結果會放置在清單方塊中。此外,還會從 RecognizerContextRecognitionEventArgs 物件的 CustomData 屬性擷取開始辨識的時間,用來計算完成辨識所需耗用的時間。
' event fires when recognition results (without alternates) are ready
Private Sub RecognizerContext_Recognition(ByVal sender As Object, _
ByVal e As RecognizerContextRecognitionEventArgs)
' when updating a control, must use Invoke() since controls are
' not thread safe and recognition occurs on a different thread
If Me.InvokeRequired Then
' recursively call this method via Invoke()
Me.Invoke( _
New RecognizerContextRecognitionEventHandler(AddressOf RecognizerContext_Recognition), _
New Object() {sender, e} _
)
Return
End If
If RecognitionStatus.NoError = e.RecognitionStatus Then
listBoxRecognitionResults.Items.Add(e.Text)
' get the custom data and calculate elapsed time
Dim startTime As DateTime = DirectCast(e.CustomData, DateTime)
Dim endTime As DateTime = DateTime.Now
Dim span As TimeSpan = New TimeSpan(endTime.Ticks - startTime.Ticks)
' display the number of seconds for this recognition to finish
listBoxRecognitionResults.Items.Add(span.TotalSeconds.ToString())
End If
End Sub
// event fires when recognition results (without alternates) are ready
private void RecognizerContext_Recognition(object sender, RecognizerContextRecognitionEventArgs e)
{
// when updating a control, must use Invoke() since controls are
// not thread safe and recognition occurs on a different thread
if (this.InvokeRequired)
{
// recursively call this method via Invoke()
this.Invoke(
new RecognizerContextRecognitionEventHandler(RecognizerContext_Recognition),
new object[] { sender, e }
);
return;
}
if (RecognitionStatus.NoError == e.RecognitionStatus)
{
listBoxRecognitionResults.Items.Add(e.Text);
// get the custom data and calculate elapsed time
DateTime startTime = (DateTime)e.CustomData;
DateTime endTime = DateTime.Now;
TimeSpan span = new TimeSpan(endTime.Ticks - startTime.Ticks);
// display the number of seconds for this recognition to finish
listBoxRecognitionResults.Items.Add(span.TotalSeconds.ToString());
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0
請參閱
參考
RecognizerContextRecognitionEventArgs 類別