ContextNode.ToString Method
Returns a human-readable type for the ContextNode object as a string.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.dll)
Syntax
'Declaration
Public Overrides Function ToString As String
'Usage
Dim instance As ContextNode
Dim returnValue As String
returnValue = instance.ToString()
public override string ToString()
public:
virtual String^ ToString() override
public override function ToString() : String
Return Value
Type: System.String
A human-readable type for the ContextNode object as a string.
Remarks
For example, if the Type is InkWord, this method returns a value of "InkWordNode".
Examples
This example is a method that recursively traverses a tree of ContextNode objects. It uses the SubNodes property and populates a TreeView by adding TreeViewItem objects. It then sets their Header property to ToString, and adds InkWordNode.GetRecognizedString or InkDrawingNode.GetShapeName if appropriate.
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);
}
}
Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0