Share via


InkAnalyzer.AddStrokes Method (StrokeCollection, Int32)

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

Namespace:  System.Windows.Ink
Assembly:  IAWinFX (in IAWinFX.dll)

Syntax

'Declaration
Public Function AddStrokes ( _
    strokesToAdd As StrokeCollection, _
    languageId As Integer _
) As ContextNode
'Usage
Dim instance As InkAnalyzer 
Dim strokesToAdd As StrokeCollection 
Dim languageId As Integer 
Dim returnValue As ContextNode 

returnValue = instance.AddStrokes(strokesToAdd, _
    languageId)
public ContextNode AddStrokes(
    StrokeCollection strokesToAdd,
    int languageId
)
public:
ContextNode^ AddStrokes(
    StrokeCollection^ strokesToAdd, 
    int languageId
)
public function AddStrokes(
    strokesToAdd : StrokeCollection, 
    languageId : int
) : ContextNode

Parameters

  • languageId
    Type: System.Int32

    The locale identifier assigned to the strokes in the strokesToAdd collection.

Return Value

Type: System.Windows.Ink.ContextNode
The ContextNode to which strokesToAdd was added.

Remarks

The InkAnalyzer adds the StrokeCollection to an UnclassifiedInkNode in the RootNode property's SubNodes collection. Each stroke in the StrokeCollection collection, strokesToAdd, is assigned the locale identifier languageId and added to the first UnclassifiedInkNode containing strokes with the same locale identifier. If no such UnclassifiedInkNode exists, a new UnclassifiedInkNode is created and strokesToAdd 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 strokes.

If any of the strokes are already attached to the InkAnalyzer, the InkAnalyzer throws an exception.

Examples

The following example creates a new InkAnalyzer and attaches the StrokesChanged event handler to the Strokes property on the InkCanvas, named theInkCanvas.

theInkAnalyzer = New InkAnalyzer()

AddHandler theInkCanvas.Strokes.StrokesChanged, AddressOf Strokes_StrokesChanged
theInkAnalyzer = new InkAnalyzer();

theInkCanvas.Strokes.StrokesChanged += 
    new StrokeCollectionChangedEventHandler(Strokes_StrokesChanged);

The following example defines the Strokes_StrokesChanged event handler, which adds strokes to theInkAnalyzer if they were already added to theInkCanvas. It also removes strokes from theInkAnalyzer if they were already removed from theInkCanvas.

' This event occurs whenever a stroke is added, removed, or partially erased 
' from the InkCanvas. 
Sub Strokes_StrokesChanged(ByVal sender As Object, ByVal e As StrokeCollectionChangedEventArgs) 
    If e.Added.Count > 0 Then
        theInkAnalyzer.AddStrokes(e.Added)
    End If 

    If e.Removed.Count > 0 Then
        theInkAnalyzer.RemoveStrokes(e.Removed)
    End If 

End Sub 'Strokes_StrokesChanged
// This event occurs whenever a stroke is added, removed, or partially erased 
// from the InkCanvas. 
void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
{
    if (e.Added.Count > 0)
    {
        theInkAnalyzer.AddStrokes(e.Added);
    }

    if (e.Removed.Count > 0)
    {
        theInkAnalyzer.RemoveStrokes(e.Removed);
    }
}

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

AddStrokes Overload

System.Windows.Ink Namespace

InkAnalyzer.AddStroke

InkAnalyzerRemoveStroke

InkAnalyzerRemoveStrokes