Freigeben über


ContextNode.ToString Method

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

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink.Analysis (in microsoft.ink.analysis.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 String ToString ()
public override function ToString () : String
Not applicable.

Return Value

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".

Example

This example is a method that recursively traverses a tree of ContextNode objects. It uses the SubNodes property and populates a System.Windows.Forms.TreeViewSystem.Windows.Forms.TreeView by adding TreeNodeTreeNode objects. It then sets their TreeNode.TextTreeNode.Text property to ToString, adding InkWordNode.GetRecognizedString or InkDrawingNode.GetShapeName if appropriate.

Private Sub WalkTree(ByVal parentContextNode As Microsoft.Ink.ContextNode, _
                     ByVal parentTreeNode As TreeNode)

    Dim cNode As ContextNode
    For Each cNode In parentContextNode.SubNodes
        Dim newTNode As New TreeNode(cNode.ToString())
        If TypeOf cNode Is Microsoft.Ink.InkWordNode Then
            newTNode.Text = newTNode.Text + _
                ": " + CType(cNode, InkWordNode).GetRecognizedString()
        ElseIf TypeOf cNode Is Microsoft.Ink.InkDrawingNode Then
            Dim shapeName As String = CType(cNode, InkDrawingNode).GetShapeName()
            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(
    Microsoft.Ink.ContextNode parentContextNode, TreeNode parentTreeNode)
{
    foreach (ContextNode cNode in parentContextNode.SubNodes)
    {
        TreeNode newTNode = new TreeNode(cNode.ToString());
        if (cNode is Microsoft.Ink.InkWordNode)
        {
            newTNode.Text +=
                ": " + ((InkWordNode)cNode).GetRecognizedString();
        }
        else if (cNode is Microsoft.Ink.InkDrawingNode)
        {
            String shapeName = ((InkDrawingNode)cNode).GetShapeName();
            if (shapeName != "")
                newTNode.Text += ": " + 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

ContextNode Class
ContextNode Members
Microsoft.Ink Namespace