Share via


ContextNodeBase.ToString Method

Returns a human-readable type for the ContextNodeBase object as a string.

Namespace: System.Windows.Ink.AnalysisCore
Assembly: IACore (in iacore.dll)

Syntax

'Declaration
Public Overrides Function ToString As String
'Usage
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
Not applicable.

Return Value

A human-readable type for the ContextNodeBase object as a string.

Remarks

For example, if the Type is InkWord, this method returns a value of "InkWordNode".

Example

This example is a method that recursively traverses a tree of ContextNodeBase objects. It uses the SubNodes property and populates a System.Windows.Forms.TreeView by adding TreeNode objects. It then sets their Text property to ToString, adding the recognized string or shape name if appropriate.

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;
    }
}

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

ContextNodeBase Class
ContextNodeBase Members
System.Windows.Ink.AnalysisCore Namespace