RecognitionResult.TopString 属性
获取 TopAlternate 属性的结果文本。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public ReadOnly Property TopString As String
用法
Dim instance As RecognitionResult
Dim value As String
value = instance.TopString
public string TopString { get; }
public:
property String^ TopString {
String^ get ();
}
/** @property */
public String get_TopString()
public function get TopString () : String
属性值
类型:System.String
TopAlternate 属性的结果文本。
备注
备注
如果调用 ModifyTopAlternate 方法引起 TopAlternate 属性发生更改,则会更改 TopString 属性的结果文本。
示例
此示例处理同步识别以响应用户操作(如单击菜单项或按钮)。首先,从 InkOverlay 对象的关联 Strokes 集合分配 RecognizerContext 对象的 Strokes 集合,并检查笔画计数。如果 Strokes 集合包含至少一个 Stroke 对象,则调用 Recognize 方法开始识别过程。如果识别成功,并且 TopConfidence(如果支持)不等于 RecognitionConfidencePoor(即为 Intermediate 或 Strong),则将 TopString 添加到列表框中进行显示。
' assign strokes collection from the collected strokes
Me.mRecognizerContext.Strokes = Me.mInkOverlay.Ink.Strokes
' check stroke count. Recognize() will throw exception if no strokes
If (Me.mRecognizerContext.Strokes.Count > 0) Then
Dim status As RecognitionStatus
' perform the recognition
Dim rResult As RecognitionResult = Me.mRecognizerContext.Recognize(status)
' see if the recognizer used supports confidence levels
Dim rSupportsConfidence As Boolean = RecognizerSupportsConfidence(mRecognizerContext.Recognizer)
' check status and TopConfidence (if supported)
If (RecognitionStatus.NoError = status And _
((rSupportsConfidence And _
rResult.TopConfidence <> RecognitionConfidence.Poor) Or _
Not rSupportsConfidence)) Then
listBoxRecognitionResults.Items.Add(rResult.TopString)
End If
End If
// assign strokes collection from the collected strokes
this.mRecognizerContext.Strokes = this.mInkOverlay.Ink.Strokes;
// check stroke count. Recognize() will throw exception if no strokes
if (this.mRecognizerContext.Strokes.Count > 0)
{
RecognitionStatus status;
// perform the recognition
RecognitionResult rResult = this.mRecognizerContext.Recognize(out status);
// see if the recognizer used supports confidence levels
bool rSupportsConfidence = RecognizerSupportsConfidence(mRecognizerContext.Recognizer);
// check status and TopConfidence (if supported)
if (RecognitionStatus.NoError == status &&
((rSupportsConfidence &&
rResult.TopConfidence != RecognitionConfidence.Poor) ||
!rSupportsConfidence))
{
listBoxRecognitionResults.Items.Add(rResult.TopString);
}
}
下面的示例演示用于确定 Recognizer 是否支持置信级别的帮助器方法。
Private Function RecognizerSupportsConfidence(ByVal pRecognizer As Recognizer) As Boolean
For Each G As Guid In pRecognizer.SupportedProperties
If G = RecognitionProperty.ConfidenceLevel Then
Return True
End If
Next
Return False
End Function
private bool RecognizerSupportsConfidence(Recognizer pRecognizer)
{
foreach (Guid G in pRecognizer.SupportedProperties)
{
if (G == RecognitionProperty.ConfidenceLevel)
{
return true;
}
}
return false;
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0