共用方式為


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

範例

在下列範例中,會說明如何從 InkAnalyzer 對 ContextNodeCollection 執行迴圈,InkAnalyzer (名為 theInkAnalyzer) 的 FindNodesOfType(ContextNodeType, ContextNode) 方法。這個範例會對 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

執行緒安全

這個型別的任何 Public 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]