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
請參閱
參考
System.Windows.Ink.AnalysisCore 命名空間
ContextNodeBase.SubNodes