ContextNode.ToString 方法
以字符串形式返回 ContextNode 对象的可读类型。
命名空间: System.Windows.Ink
程序集: IAWinFX(在 IAWinFX.dll 中)
语法
声明
Public Overrides Function ToString As String
用法
Dim instance As ContextNode
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
ContextNode 对象的字符串形式的可读类型。
备注
例如,如果 Type 为 InkWord,则此方法返回值“InkWordNode”。
示例
此示例演示的方法递归遍历一个 ContextNode 对象树。它使用 SubNodes 属性并通过添加 TreeViewItem 对象来填充 TreeView。然后,将这些对象的 Header 属性设置为 ToString,并根据需要添加 InkWordNode.GetRecognizedString 或 InkDrawingNode.GetShapeName。
Private Shared Sub WalkTree(ByVal parentContextNode As ContextNode, ByVal parentTreeNode As TreeViewItem)
parentTreeNode.IsExpanded = True
For Each theContextSubnode As ContextNode In parentContextNode.SubNodes
Dim newTreeNode As New TreeViewItem()
newTreeNode.Header = theContextSubnode.ToString()
If TypeOf theContextSubnode Is InkWordNode Then
newTreeNode.Header += ": " + CType(theContextSubnode, InkWordNode).GetRecognizedString()
ElseIf TypeOf theContextSubnode Is InkDrawingNode Then
newTreeNode.Header += ": " + CType(theContextSubnode, InkDrawingNode).GetShapeName()
End If
' If the context node is confirmed, add a note to the
' tree view item.
If (theContextSubnode.IsConfirmed(ConfirmationType.NodeTypeAndProperties)) Then
newTreeNode.Header += " Confirmed."
End If
' Add the context node as a tag of the tree view item and
' add the new tree view item to the parent node.
newTreeNode.Tag = theContextSubnode
parentTreeNode.Items.Add(newTreeNode)
WalkTree(theContextSubnode, newTreeNode)
Next theContextSubnode
End Sub 'WalkTree
private static void WalkTree(ContextNode parentContextNode, TreeViewItem parentTreeNode)
{
// Expand the current TreeViewItem.
parentTreeNode.IsExpanded = true;
foreach (ContextNode theContextSubnode
in parentContextNode.SubNodes)
{
TreeViewItem newTreeNode = new TreeViewItem();
newTreeNode.Header = theContextSubnode.ToString();
if (theContextSubnode is InkWordNode)
{
newTreeNode.Header += ": " +
((InkWordNode)theContextSubnode).GetRecognizedString();
}
else if (theContextSubnode is InkDrawingNode)
{
newTreeNode.Header += ": " +
((InkDrawingNode)theContextSubnode).GetShapeName();
}
// If the context node is confirmed, add a note to the
// tree view item.
if (theContextSubnode.IsConfirmed(ConfirmationType.NodeTypeAndProperties))
{
newTreeNode.Header += " Confirmed.";
}
// Add the context node as a tag of the tree view item and
// add the new tree view item to the parent node.
newTreeNode.Tag = theContextSubnode;
parentTreeNode.Items.Add(newTreeNode);
WalkTree(theContextSubnode, newTreeNode);
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0