다음을 통해 공유


RootNode.GetNodesFromTextRange 메서드 (Int32%, Int32%)

업데이트: 2007년 11월

인식된 문자열의 지정된 텍스트 범위와 관련된 하위 ContextNode 개체의 컬렉션을 반환합니다.

네임스페이스:  Microsoft.Ink
어셈블리:  Microsoft.Ink.Analysis(Microsoft.Ink.Analysis.dll)

구문

‘선언
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
‘사용 방법
Dim instance As RootNode
Dim start As Integer
Dim length As Integer
Dim returnValue As ContextNodeCollection

returnValue = instance.GetNodesFromTextRange(start, _
    length)
public ContextNodeCollection GetNodesFromTextRange(
    ref int start,
    ref int length
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
    int% start, 
    int% length
)
public ContextNodeCollection GetNodesFromTextRange(
    /** @ref */int start,
    /** @ref */int length
)
public function GetNodesFromTextRange(
    start : int, 
    length : int
) : ContextNodeCollection

매개 변수

  • start
    형식: System.Int32%
    인식된 문자열의 텍스트 범위 시작 위치입니다.
  • length
    형식: System.Int32%
    인식된 문자열의 텍스트 범위 길이입니다.

반환 값

형식: Microsoft.Ink.ContextNodeCollection
인식된 문자열의 지정된 텍스트 범위와 관련된 하위 ContextNode 개체의 컬렉션입니다.

설명

start 및 length 매개 변수의 값은 변경될 수 있으므로 이러한 매개 변수는 참조입니다. 예를 들어 GetRecognizedString의 반환 값이 "I am late"인 경우 start 값을 6으로, length 값을 문자 "a"에 해당하는 1로 전달하면 ContextNodeCollection에는 "late"라는 단어에 해당하는 InkWordNodeContextNode 하나만 들어 있을 가능성이 높습니다. 이러한 경우 "late"라는 전체 단어에 따라 start의 값이 5로 변경되고 length의 값이 4로 변경됩니다.

예제

다음 예제에서는 해당 Text 속성이 InkAnalyzer인 theInkAnalyzer의 RootNode에 대한 GetRecognizedString에서 반환된 값으로 설정된 TextBox인 theResultsTextBox를 사용합니다. 사용자가 TextBox에서 일부 텍스트를 선택했으며, 예제 코드에서는 선택 영역을 받아 이 선택 영역에 해당하는 Strokes를 표시합니다.

Dim theRootNode As RootNode = DirectCast(theInkAnalyzer.RootNode, RootNode)
' Find out what's been selected in the text box
Dim selStart As Integer = theResultsTextBox.SelectionStart
Dim selLength As Integer = theResultsTextBox.SelectionLength

' Return if no text is selected.
' selLength must be > 0 or GetNodesFromTextRange(...) 
' will throw an ArgumentOutOfRangeException
If 0 = selLength Then
    Return
End If

' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = theRootNode.GetNodesFromTextRange(selStart, selLength)

' Use the new start and length value to update the
' selection in the TextBox
theResultsTextBox.SelectionStart = selStart
theResultsTextBox.SelectionLength = selLength

' First, set all strokes to black
Dim inkStroke As Stroke
For Each inkStroke In theRootNode.Strokes
    inkStroke.DrawingAttributes = New DrawingAttributes(Color.Black)
Next inkStroke
' Next, set all selected sub nodes to red
Dim node As ContextNode
For Each node In selectedSubNodes
    For Each inkStroke In node.Strokes
        inkStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
    Next inkStroke
Next node
            RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
            // Find out what's been selected in the text box
            int selStart = theResultsTextBox.SelectionStart;
            int selLength = theResultsTextBox.SelectionLength;


            // Return if no text is selected.
            // selLength must be > 0 or GetNodesFromTextRange(...) 
            // will throw an ArgumentOutOfRangeException
            if (0 == selLength)
            {
                return;
            }

            // Get the nodes that correspond to that range
            ContextNodeCollection selectedSubNodes =
                    theRootNode.GetNodesFromTextRange(ref selStart, ref selLength);


            // Use the new start and length value to update the
            // selection in the TextBox
            theResultsTextBox.SelectionStart = selStart;
            theResultsTextBox.SelectionLength = selLength;

            // First, set all strokes to black
            foreach (Stroke stroke in theRootNode.Strokes)
                stroke.DrawingAttributes =
                            new DrawingAttributes(Color.Black);
            // Next, set all selected sub nodes to red
            foreach (ContextNode node in selectedSubNodes)
            {
                foreach (Stroke stroke in node.Strokes)
                {
                    stroke.DrawingAttributes =
                            new DrawingAttributes(Color.Red);
                }
            }

플랫폼

Windows Vista

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

RootNode 클래스

RootNode 멤버

GetNodesFromTextRange 오버로드

Microsoft.Ink 네임스페이스