RecognitionResult.SetResultOnStrokes 方法
將 RecognitionResult 物件指派至用來產生結果的 Strokes 集合。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public Sub SetResultOnStrokes
'用途
Dim instance As RecognitionResult
instance.SetResultOnStrokes()
public void SetResultOnStrokes()
public:
void SetResultOnStrokes()
public void SetResultOnStrokes()
public function SetResultOnStrokes()
備註
如果將辨識結果自動指派至每個 Strokes 集合,系統效能可能會降低。因此,根據預設,結果不會附加至 Strokes 集合。若要將結果指派至 SetResultOnStrokes 集合,您必須呼叫 Strokes 方法。若要傳回 Strokes 集合的辨識結果,請使用 Strokes 集合的 RecognitionResult 屬性。將結果指派至 Strokes 集合之後,您就可以在 CustomStrokes 集合中儲存「筆劃」。這些自訂筆劃以及 RecognitionResult 可加以保存及擷取供日後使用。
範例
在這個範例中,會處理同步辨識以回應使用者動作,例如按一下功能表項目或按鈕。首先,會從與 InkOverlay 物件相關聯的 Strokes 集合指派 RecognizerContext 物件的 Strokes 集合,並檢查筆劃計數。如果 Strokes 集合包含至少一個 Stroke 物件,則辨識程序會先呼叫 Recognize 方法。如果辨識成功,則會呼叫 SetResultOnStrokes 方法,將 RecognizerContext 物件附加至其對應的 Strokes 集合。最後,再將 Strokes 集合儲存為具名的 CustomStrokes 集合。這也會儲存附加的 RecognitionResult。
' 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)
' check status
If RecognitionStatus.NoError = status Then
' attach RecognitionResult to the Strokes collection
rResult.SetResultOnStrokes()
' save the strokes collection (with RecognitionResult attached)
Try
mInkOverlay.Ink.CustomStrokes.Add("customCollectionName", rResult.Strokes)
Catch ex As ArgumentException
' this exception is raised when the named collection already exists
End Try
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);
// check status
if (RecognitionStatus.NoError == status)
{
// attach RecognitionResult to the Strokes collection
rResult.SetResultOnStrokes();
// save the strokes collection (with RecognitionResult attached)
try
{
mInkOverlay.Ink.CustomStrokes.Add("customCollectionName", rResult.Strokes);
}
catch (ArgumentException)
{
// this exception is raised when the named collection already exists
}
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0