Compartir a través de


ContextNode.SubNodes Property

Gets the direct children of the ContextNode object.

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

Syntax

'Declaration
Public ReadOnly Property SubNodes As ContextNodeCollection
'Usage
Dim instance As ContextNode
Dim value As ContextNodeCollection

value = instance.SubNodes
public ContextNodeCollection SubNodes { get; }
public:
property ContextNodeCollection^ SubNodes {
    ContextNodeCollection^ get ();
}
/** @property */
public ContextNodeCollection get_SubNodes ()
public function get SubNodes () : ContextNodeCollection
Not applicable.

Property Value

The direct children of the ContextNode object.

Remarks

This returns only the direct children, not all of the descendants.

Example

This example is a method that recursively traverses a tree of ContextNode objects. It uses the SubNodes property and populates a System.Windows.Forms.TreeViewSystem.Windows.Forms.TreeView by adding TreeNodeTreeNode objects. It then sets their Text properties to GetRecognizedString.

Private Sub WalkTree(ByVal parentContextNode As Microsoft.Ink.ContextNode, _
                     ByVal parentTreeNode As TreeNode)

    Dim cNode As ContextNode
    For Each cNode In parentContextNode.SubNodes
        Dim newTNode As New TreeNode(cNode.ToString())
        If TypeOf cNode Is Microsoft.Ink.InkWordNode Then
            newTNode.Text = newTNode.Text + _
                ": " + CType(cNode, InkWordNode).GetRecognizedString()
        ElseIf TypeOf cNode Is Microsoft.Ink.InkDrawingNode Then
            Dim shapeName As String = CType(cNode, InkDrawingNode).GetShapeName()
            If shapeName <> "" Then
                newTNode.Text = newTNode.Text + ": " + shapeName
            End If
        End If
        WalkTree(cNode, newTNode)
        parentTreeNode.Nodes.Add(newTNode)

        ' Add the context node as a tag of the tree node
        newTNode.Tag = cNode
    Next cNode

End Sub 'WalkTree
private void WalkTree(
    Microsoft.Ink.ContextNode parentContextNode, TreeNode parentTreeNode)
{
    foreach (ContextNode cNode in parentContextNode.SubNodes)
    {
        TreeNode newTNode = new TreeNode(cNode.ToString());
        if (cNode is Microsoft.Ink.InkWordNode)
        {
            newTNode.Text +=
                ": " + ((InkWordNode)cNode).GetRecognizedString();
        }
        else if (cNode is Microsoft.Ink.InkDrawingNode)
        {
            String shapeName = ((InkDrawingNode)cNode).GetShapeName();
            if (shapeName != "")
                newTNode.Text += ": " + shapeName;
        }
        WalkTree(cNode, newTNode);
        parentTreeNode.Nodes.Add(newTNode);

        // Add the context node as a tag of the tree node
        newTNode.Tag = cNode;
    }
}

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

ContextNode Class
ContextNode Members
Microsoft.Ink Namespace
ContextNode.ParentNode