Share via


InkAnalyzer.AddStroke Method (Stroke, Int32)

Adds a stroke to the InkAnalyzer and assigns a specific locale identifier to the stroke.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Syntax

'Declaration
Public Function AddStroke ( _
    strokeToAdd As Stroke, _
    languageId As Integer _
) As ContextNode
'Usage
Dim instance As InkAnalyzer 
Dim strokeToAdd As Stroke 
Dim languageId As Integer 
Dim returnValue As ContextNode 

returnValue = instance.AddStroke(strokeToAdd, _
    languageId)
public ContextNode AddStroke(
    Stroke strokeToAdd,
    int languageId
)
public:
ContextNode^ AddStroke(
    Stroke^ strokeToAdd, 
    int languageId
)
public function AddStroke(
    strokeToAdd : Stroke, 
    languageId : int
) : ContextNode

Parameters

  • languageId
    Type: System.Int32

    The locale identifier to assign to strokeToAdd.

Return Value

Type: Microsoft.Ink.ContextNode
The ContextNode to which strokeToAdd was added.

Remarks

The InkAnalyzer adds the Stroke to an UnclassifiedInkNode in the RootNode property's SubNodes collection. The Stroke, strokeToAdd, is assigned the locale identifier languageId and is added to the first UnclassifiedInkNode containing strokes with the same locale identifier. If no such UnclassifiedInkNode exists, a new UnclassifiedInkNode is created and strokeToAdd is added to the new UnclassifiedInkNode.

This method expands the DirtyRegion to the union of the region's current value and the bounding box of the added stroke.

If the stroke is already attached to the InkAnalyzer, the InkAnalyzer throws an exception.

Examples

This example does the following.

' Create and enable the InkCollector and attach event handlers. 
Me.theInkCollector = New Microsoft.Ink.InkCollector(Me.theInkingPanel)
AddHandler Me.theInkCollector.Stroke, AddressOf Me.theInkCollector_Stroke
Me.theInkCollector.Enabled = True 

' Create the InkAnalyzer. 
Me.theInkAnalyzer = New Microsoft.Ink.InkAnalyzer(Me.theInkCollector.Ink, Me)
// Create and enable the InkCollector and attach event handlers. 
this.theInkCollector =
    new Microsoft.Ink.InkCollector(this.theInkingPanel);
this.theInkCollector.Stroke +=
    new Microsoft.Ink.InkCollectorStrokeEventHandler(
        this.theInkCollector_Stroke);
this.theInkCollector.Enabled = true;

// Create the InkAnalyzer. 
this.theInkAnalyzer =
    new Microsoft.Ink.InkAnalyzer(this.theInkCollector.Ink, this);

In this example, the theInkCollector_Stroke event handler then takes the stroke that has been added to the theInkCollector, adds it to theInkAnalyzer, and assigns a specific locale identifier, theLanguageId, to it.

''' <summary> 
''' The ink collector's InkAdded event handler. 
''' </summary> 
''' <param name="sender">The source of the event.</param> 
''' <param name="e">The event data.</param> 
Sub theInkCollector_Stroke2( _
    ByVal sender As Object, ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs)

    ' Add the new stroke to the InkAnalyzer using a specific language identifier. 
    Me.theInkAnalyzer.AddStroke(e.Stroke, Me.theLanguageId)

End Sub 'theInkCollector_Stroke2
/// <summary> 
/// The ink collector's Stroke event handler. 
/// </summary> 
/// <param name="sender">The source of the event.</param>
/// <param name="e">The event data.</param>
void theInkCollector_Stroke2(
    object sender, Microsoft.Ink.InkCollectorStrokeEventArgs e)
{
    // Add the new stroke to the InkAnalyzer using a specific 
    // language identifier. 
    this.theInkAnalyzer.AddStroke(e.Stroke, this.theLanguageId);
}

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

See Also

Reference

InkAnalyzer Class

InkAnalyzer Members

AddStroke Overload

Microsoft.Ink Namespace

InkAnalyzer.AddStrokes

InkAnalyzer.RemoveStroke

InkAnalyzer.RemoveStrokes