次の方法で共有


InkAnalyzer.AddStrokes Method (StrokeCollection)

Adds the specified StrokeCollection to the InkAnalyzer and assigns the active input thread's locale identifier to each stroke.

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

Syntax

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

returnValue = instance.AddStrokes(strokesToAdd)
public ContextNode AddStrokes (
    StrokeCollection strokesToAdd
)
public:
ContextNode^ AddStrokes (
    StrokeCollection^ strokesToAdd
)
public ContextNode AddStrokes (
    StrokeCollection strokesToAdd
)
public function AddStrokes (
    strokesToAdd : StrokeCollection
) : ContextNode
Not applicable.

Parameters

Return Value

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 of the active input thread 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 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.

Example

The following example creates a new InkAnalyzer and attaches the StrokesChanged event handler to the Strokes property on the InkCanvas, 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 the strokes that have been added to theInkCanvas to theInkAnalyzer and removes the strokes that have been removed from theInkCanvas from theInkAnalyzer.

' 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 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

InkAnalyzer Class
InkAnalyzer Members
System.Windows.Ink Namespace
System.Windows.Ink.InkAnalyzer.AddStroke
System.Windows.Ink.InkAnalyzer.RemoveStroke
System.Windows.Ink.InkAnalyzer.RemoveStrokes