RecognitionResult.Strokes 屬性
取得「辨識器」用來產生 RecognitionResult 物件的 Strokes 集合。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public ReadOnly Property Strokes As Strokes
'用途
Dim instance As RecognitionResult
Dim value As Strokes
value = instance.Strokes
public Strokes Strokes { get; }
public:
property Strokes^ Strokes {
Strokes^ get ();
}
/** @property */
public Strokes get_Strokes()
public function get Strokes () : Strokes
屬性值
型別:Microsoft.Ink.Strokes
「辨識器」用來產生 RecognitionResult 物件的 Strokes 集合。
備註
根據預設,RecognitionResult 物件不會附加至 Strokes 集合。若要將結果指派至 Strokes 集合,您必須呼叫 RecognitionResult 物件的 SetResultOnStrokes 方法。
範例
在這個範例中,會處理同步辨識以回應使用者動作,例如按一下功能表項目或按鈕。首先,會從與 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);
}
}
下列範例說明 Helper 方法,這個方法可用來判斷 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