RecognizerContextRecognitionWithAlternatesEventArgs.RecognitionStatus 属性
获取 RecognitionStatus 枚举值之一,该值指示产生最新识别结果时的识别状态。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public ReadOnly Property RecognitionStatus As RecognitionStatus
用法
Dim instance As RecognizerContextRecognitionWithAlternatesEventArgs
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 集合中,并调用 BackgroundRecognizeWithAlternates 方法,调用时将当前时间传递给 customData 参数。
Private Sub mInkOverlay_Stroke3(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.BackgroundRecognizeWithAlternates(DateTime.Now)
End Sub
private void mInkOverlay_Stroke3(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.BackgroundRecognizeWithAlternates(DateTime.Now);
}
完成后台识别时将激发 RecognitionWithAlternates 事件。在处理此事件的过程中,会将识别结果(包括备选项)放入一个列表框。此外,还将从 RecognizerContextRecognitionWithAlternatesEventArgs 对象的 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
另请参见
参考
RecognizerContextRecognitionWithAlternatesEventArgs 类
RecognizerContextRecognitionWithAlternatesEventArgs 成员
RecognizerContextRecognitionWithAlternatesEventArgs