ContextNodeBase.ToString 方法
返回 ContextNodeBase 对象的可读字符串类型。
命名空间: System.Windows.Ink.AnalysisCore
程序集: IACore(在 IACore.dll 中)
语法
声明
Public Overrides Function ToString As String
用法
Dim instance As ContextNodeBase
Dim returnValue As String
returnValue = instance.ToString()
public override string ToString()
public:
virtual String^ ToString() override
public String ToString()
public override function ToString() : String
返回值
类型:System.String
ContextNodeBase 对象的可读字符串类型。
备注
例如,如果 Type 为 InkWord,则此方法返回值“InkWordNode”。
示例
此示例演示的方法递归遍历一个 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