Share via


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 void SetResultOnStrokes ()
public function SetResultOnStrokes ()
Not applicable.

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 stroke in a CustomStrokes collection. These custom strokes, as well as the RecognitionResult, can be persisted and retrieved for later use.

Example

This C# example tracks the RecognitionResult object and its RecognitionAlternate objects. The example then saves the RecognitionResult objects with the Stroke objects that are recognized by using the SetResultOnStrokes method. Finally, the example modifies the TopAlternate property of the RecognitionResult object based on user input.

[C#]

// Declarations...
InkCollector theInkCollector;
Strokes theStrokes;
RecognizerContext theRecognizerContext;
RecognitionResult theRecognitionResult;

// Initialization...

// Initialize the recognizer's strokes
// and assign them to the context.
theStrokes = theInkCollector.Ink.Strokes;
theRecognizerContext = new RecognizerContext();
theRecognizerContext.Strokes = theStrokes;

// Install event handlers.
theRecognizerContext.RecognitionWithAlternates +=
    new RecognizerContextRecognitionWithAlternatesEventHandler(
        RecognitionWithAlternates_Event);

//...

// Recognition Event Handler
private void RecognitionWithAlternates_Event(
    object sender,
    RecognizerContextRecognitionWithAlternatesEventArgs e)
{
    // Save the RecognitionResult, and copy it to the strokes
    theRecognitionResult = e.Result;
    theRecognitionResult.SetResultOnStrokes();
}

// Modify the TopAlternate of the result
private void buttonAlt2_Click(object sender, System.EventArgs e)
{
    RecognitionAlternates theRecognitionAlternates =
        theRecognitionResult.GetAlternatesFromSelection(0, -1);
    theRecognitionResult.ModifyTopAlternate(theRecognitionAlternates[2]);
}

This Microsoft® Visual Basic® .NET example tracks the RecognitionResult object and its RecognitionAlternate objects. The example then saves the RecognitionResult objects with the Stroke objects that are recognized by using the SetResultOnStrokes method. Finally, the example modifies the TopAlternate property of the RecognitionResult object based on user input.

[Visual Basic]

'Declarations...
Dim theInkCollector As InkCollector
Dim theStrokes As Strokes
Dim theRecognizerContext As RecognizerContext
Dim theRecognitionResult As RecognitionResult

'Initialization...

'Initialize the recognizer's strokes
'and assign them to the context.
theStrokes = theInkCollector.Ink.Strokes
theRecognizerContext = new RecognizerContext()
theRecognizerContext.Strokes = theStrokes

'Install event handlers.
AddHandler theRecognizerContext.RecognitionWithAlternates, _
AddressOf RecognitionWithAlternates_Event

'...

'Recognition Event Handler
Private Sub RecognitionWithAlternates_Event( _
ByVal sender As Object, _
ByVal e As RecognizerContextRecognitionWithAlternatesEventArgs)
    'Save the RecognitionResult, and copy it to the strokes.
    theRecognitionResult = e.Result
    theRecognitionResult.SetResultOnStrokes()
End Sub

'Modify the TopAlternate of the result
Private Sub ButtonAlt2_Click(object sender, System.EventArgs e) _
Handles ButtonAlt2.Click
    RecognitionAlternates theRecognitionAlternates =
        theRecognitionResult.GetAlternatesFromSelection(0, -1)
    theRecognitionResult.ModifyTopAlternate(theRecognitionAlternates(2))
End Sub

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

RecognitionResult Class
RecognitionResult Members
Microsoft.Ink Namespace
Strokes
CustomStrokes