다음을 통해 공유


ContextNode.ToString 메서드

업데이트: 2007년 11월

사람이 인식할 수 있는 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 개체 형식(문자열)입니다.

설명

예를 들어 TypeInkWord인 경우 이 메서드는 "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에서 지원

참고 항목

참조

ContextNode 클래스

ContextNode 멤버

System.Windows.Ink 네임스페이스