Partager via


ContextNodeBaseCollection, classe

Mise à jour : November 2007

Contient une collection d'objets ContextNodeBase qui sont le résultat d'une analyse d'entrée manuscrite.

Espace de noms :  System.Windows.Ink.AnalysisCore
Assembly :  IACore (dans IACore.dll)

Syntaxe

'Déclaration
Public Class ContextNodeBaseCollection _
    Implements ICollection, IEnumerable
'Utilisation
Dim instance As ContextNodeBaseCollection
public class ContextNodeBaseCollection : ICollection, 
    IEnumerable
public ref class ContextNodeBaseCollection : ICollection, 
    IEnumerable
public class ContextNodeBaseCollection implements ICollection, 
    IEnumerable
public class ContextNodeBaseCollection implements ICollection, IEnumerable

Exemples

L'exemple suivant montre comment parcourir en boucle un ContextNodeBaseCollection à partir du InkAnalyzerBase. FindNodesOfType d'un InkAnalyzerBase nommé theInkAnalyzerBase. L'exemple parcourt en boucle tous les nœuds de ligne et les marque en rouge si deux nœuds de mot manuscrit sont présents et contiennent le même mot.

' 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 ContextNodeBaseCollection = _
    theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line)

For Each lineNode As ContextNodeBase In lines

    Dim previousWord As ContextNodeBase = Nothing
    Dim previousWordRecognizedString As String = ""

    For Each inkWord As ContextNodeBase In _
        theInkAnalyzerBase.FindNodesOfType(ContextNodeTypeBase.InkWord, lineNode)

        Dim inkWordRecognizedString As String = ""

        If inkWord.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString) Then
            inkWordRecognizedString = _
                CType(inkWord.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString), String)
        End If

        ' TODO: I think I can get rid of this and just assign the previous string 
        ' to the current string
        If Not previousWord Is Nothing Then

            previousWordRecognizedString = _
            CType(previousWord.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString), String)

        End If

        If previousWordRecognizedString <> "" Then

            Dim previousWordStrokes As Strokes = theInk.CreateStrokes(previousWord.GetStrokeIds())
            Dim inkWordStrokes As Strokes = theInk.CreateStrokes(previousWord.GetStrokeIds())

            For Each aStroke As Stroke In previousWordStrokes
                aStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
            Next aStroke

            For Each aStroke As Stroke In inkWordStrokes
                aStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
            Next aStroke
        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.
ContextNodeBaseCollection lines =
    theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line);
foreach (ContextNodeBase lineNode in lines)
{
    ContextNodeBase previousWord = null;
    string previousWordRecognizedString = "";
    foreach (ContextNodeBase inkWord in 
        theInkAnalyzerBase.FindNodesOfType(ContextNodeTypeBase.InkWord, lineNode))
    {
        string inkWordRecognizedString = "";

        if (inkWord.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString))
        {
            inkWordRecognizedString =
                (string)inkWord.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString);
        }

        // TODO: I think I can get rid of this and just assign the previous string 
        // to the current string
        if (previousWord != null &&
            previousWord.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString))
        {
            previousWordRecognizedString =
                (string)previousWord.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString);
        }

        if (previousWordRecognizedString != "" &&
            previousWordRecognizedString == inkWordRecognizedString)
        {
            Strokes previousWordStrokes = theInk.CreateStrokes(previousWord.GetStrokeIds());
            Strokes inkWordStrokes = theInk.CreateStrokes(previousWord.GetStrokeIds());

            foreach (Stroke stroke in previousWordStrokes)
                stroke.DrawingAttributes = new DrawingAttributes(Color.Red);

            foreach (Stroke stroke in inkWordStrokes)
                stroke.DrawingAttributes = new DrawingAttributes(Color.Red);
        }
        previousWord = inkWord;
    }
}

Hiérarchie d'héritage

System.Object
  System.Windows.Ink.AnalysisCore.ContextNodeBaseCollection

Sécurité des threads

Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Plateformes

Windows Vista, Windows XP SP2, Windows Server 2003

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Informations de version

.NET Framework

Pris en charge dans : 3.0

Voir aussi

Référence

Membres ContextNodeBaseCollection

System.Windows.Ink.AnalysisCore, espace de noms