ContextNodeBase.SubNodes 属性

获取 ContextNodeBase 对象的直接子级。

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

语法

声明
Public ReadOnly Property SubNodes As ContextNodeBaseCollection
用法
Dim instance As ContextNodeBase
Dim value As ContextNodeBaseCollection

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

属性值

类型:System.Windows.Ink.AnalysisCore.ContextNodeBaseCollection
ContextNodeBase 对象的直接子级。

备注

此属性只返回直接子级,而不是所有后代。

示例

此示例演示的方法递归遍历一个 ContextNodeBase 对象树。示例中使用了 SubNodes 属性,并通过添加 TreeNode 对象填充 System.Windows.Forms.TreeView。然后,将这些树节点的 Text 属性设置为 ToString,从而添加已识别字符串或形状名称(如果合适)。

Private Sub WalkTree(ByVal parentContextNode As ContextNodeBase, ByVal parentTreeNode As TreeNode)

    Dim cNode As ContextNodeBase

    For Each cNode In parentContextNode.SubNodes

        Dim newTNode As New TreeNode(cNode.ToString())

        If cNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord AndAlso _
           cNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString) Then

            newTNode.Text = newTNode.Text + _
                ": " + CType(cNode.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString), _
                String)

        ElseIf cNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkDrawing AndAlso _
               cNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.ShapeName) Then

            Dim shapeName As String = CType(cNode.GetPropertyData(PropertyGuidsForContextNodesBase.ShapeName), _
                String)

            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(
    System.Windows.Ink.AnalysisCore.ContextNodeBase parentContextNode, TreeNode parentTreeNode)
{
    foreach (ContextNodeBase cNode in parentContextNode.SubNodes)
    {
        TreeNode newTNode = new TreeNode(cNode.ToString());
        if ((cNode.Type == System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord) &&
             cNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString))
        {
            // Get the recognized string
            newTNode.Text += ": " +
                (string)cNode.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString);
        }
        else if ((cNode.Type == System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkDrawing) &&
                  cNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.ShapeName))
        {
            newTNode.Text += ": " +
                (string)cNode.GetPropertyData(PropertyGuidsForContextNodesBase.ShapeName);
        }
        WalkTree(cNode, newTNode);
        parentTreeNode.Nodes.Add(newTNode);

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

平台

Windows Vista, Windows XP SP2, Windows Server 2003

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ContextNodeBase 类

ContextNodeBase 成员

System.Windows.Ink.AnalysisCore 命名空间

ContextNodeBase.SubNodes

ContextNodeBase.ParentNode