ContextNodeCollection 类

包含作为墨迹分析结果的 ContextNode 对象的集合。

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public Class ContextNodeCollection _
    Implements ICollection, IEnumerable
用法
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

示例

下面的示例演示如何从名为 theInkAnalyzer 的 InkAnalyzer 的 ContextNodeCollection.FindNodesOfType(ContextNodeType, ContextNode) 方法遍历 ContextNodeCollection。该示例遍历 LineNode 对象的集合,如果两个连续 InkWordNode 对象是相同的单词,则将这两个对象的笔画标记成红色。

' 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(ContextNodeType.Line)
Dim lineNode As ContextNode
For Each lineNode In  lines
    Dim previousWord As InkWordNode = Nothing

    For Each inkWord As InkWordNode In _
        theInkAnalyzer.FindNodesOfType(ContextNodeType.InkWord, lineNode)

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

            For Each stroke As Stroke In previousWord.Strokes
                stroke.DrawingAttributes.Color = Colors.Red
            Next stroke

            For Each stroke As Stroke In inkWord.Strokes
                stroke.DrawingAttributes.Color = Colors.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(ContextNodeType.Line);
foreach (ContextNode lineNode in lines)
{
    InkWordNode previousWord = null;
    foreach (InkWordNode inkWord in
             theInkAnalyzer.FindNodesOfType(ContextNodeType.InkWord, lineNode))
    {
        if (previousWord != null &&
            previousWord.GetRecognizedString() == inkWord.GetRecognizedString())
        {
            foreach (Stroke stroke in previousWord.Strokes)
                stroke.DrawingAttributes.Color = Colors.Red;
            foreach (Stroke stroke in inkWord.Strokes)
                stroke.DrawingAttributes.Color = Colors.Red;
        }
        previousWord = inkWord;
    }
}

继承层次结构

System.Object
  System.Windows.Ink.ContextNodeCollection

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ContextNodeCollection 成员

System.Windows.Ink 命名空间

ContextNode

[O:System.Windows.Ink.InkAnalyzer.FindNodes]

[O:System.Windows.Ink.InkAnalyzer.FindNodesOfType]