RecognitionResult.SetResultOnStrokes Method
Assigns the RecognitionResult object to the Strokes collection that was used to generate the results.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Sub SetResultOnStrokes
'Usage
Dim instance As RecognitionResult
instance.SetResultOnStrokes()
public void SetResultOnStrokes()
public:
void SetResultOnStrokes()
public function SetResultOnStrokes()
Remarks
System performance suffers if recognition results are automatically assigned to every Strokes collection. Therefore results are not attached to a Strokes collection by default. To assign results to a Strokes collection, you must call the SetResultOnStrokes method. To return the recognition results for a Strokes collection, use the RecognitionResult property of the Strokes collection. After you assign results to a Strokes collection, you can then store the strokes in a CustomStrokes collection. These custom strokes, as well as the RecognitionResult, can be persisted and retrieved for later use.
Examples
In this example, synchronous recognition is handled in response to a user action such as clicking on a menu item or a button. First, the Strokes collection of a RecognizerContext object is assigned from the Strokes collection associated with an InkOverlay object, and checked for stroke count. If the Strokes collection contains at least one Stroke object, the recognition process begins with a call to the Recognize method. If recognition is successful, the SetResultOnStrokes method is called to attach the RecognizerContext object to its corresponding Strokes collection. Finally, the Strokes collection is saved as a named CustomStrokes collection. This saves the attached RecognitionResult as well.
' 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
}
}
}
Platforms
Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0