다음을 통해 공유


ContextNodeCollection Class

Contains a collection of ContextNode objects that are the result of an ink analysis.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink.Analysis (in microsoft.ink.analysis.dll)

Syntax

'Declaration
Public Class ContextNodeCollection
    Implements ICollection, IEnumerable
'Usage
Dim instance As ContextNodeCollection
public class ContextNodeCollection : ICollection, IEnumerable
public ref class ContextNodeCollection : ICollection, IEnumerable
public class ContextNodeCollection implements ICollection, IEnumerable
public class ContextNodeCollection implements ICollection, IEnumerable
Not applicable.

Example

The following example shows how to loop through a ContextNodeCollection from the InkAnalyzer. FindNodesOfType method of an InkAnalyzer, theInkAnalyzer. The example loops through all of the line nodes and, if two ink word nodes are present with the same word, then it marks them as red.

' If two identical ink words occur next to each other, mark them as red.
' Note: This doesn't actually look for pairs that go across two lines.
Dim lines As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line)
Dim lineNode As ContextNode
Dim stroke As Stroke

For Each lineNode In lines

    Dim previousWord As InkWordNode = Nothing
    Dim inkWord As InkWordNode
    For Each inkWord In _
        theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.InkWord, lineNode)

        If Not (previousWord Is Nothing) AndAlso _
                previousWord.GetRecognizedString() = inkWord.GetRecognizedString() Then

            For Each stroke In previousWord.Strokes
                stroke.DrawingAttributes = New DrawingAttributes(Color.Red)
            Next stroke
            For Each stroke In inkWord.Strokes
                stroke.DrawingAttributes = New DrawingAttributes(Color.Red)
            Next stroke
        End If
        previousWord = inkWord
    Next inkWord
Next lineNode
// If two identical ink words occur next to each other, mark them as red.
// Note: This doesn't actually look for pairs that go across two lines.
ContextNodeCollection lines = 
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line);
foreach (ContextNode lineNode in lines)
{
    InkWordNode previousWord = null;
    foreach (InkWordNode inkWord in 
             theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.InkWord, lineNode))
    {
        if (previousWord != null &&
            previousWord.GetRecognizedString() == inkWord.GetRecognizedString())
        {
            foreach (Stroke stroke in previousWord.Strokes)
                stroke.DrawingAttributes = new DrawingAttributes(Color.Red);
            foreach (Stroke stroke in inkWord.Strokes)
                stroke.DrawingAttributes = new DrawingAttributes(Color.Red);
        }
        previousWord = inkWord;
    }
}

Inheritance Hierarchy

System.Object
  Microsoft.Ink.ContextNodeCollection

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

ContextNodeCollection Members
Microsoft.Ink Namespace
ContextNode
FindNodes
InkAnalyzer.FindNodesOfType