다음을 통해 공유


WritingRegionNode.GetTextRangeFromNodes 메서드

업데이트: 2007년 11월

ContextNode 개체의 컬렉션이 주어지는 경우 이 메서드는 인식된 문자열에서 해당하는 텍스트 범위를 찾습니다.

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

구문

‘선언
Public Sub GetTextRangeFromNodes ( _
    subTree As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
‘사용 방법
Dim instance As WritingRegionNode
Dim subTree As ContextNodeCollection
Dim start As Integer
Dim length As Integer

instance.GetTextRangeFromNodes(subTree, _
    start, length)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    out int start,
    out int length
)
public:
void GetTextRangeFromNodes(
    ContextNodeCollection^ subTree, 
    [OutAttribute] int% start, 
    [OutAttribute] int% length
)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    /** @attribute OutAttribute */ /** @ref */int start,
    /** @attribute OutAttribute */ /** @ref */int length
)
public function GetTextRangeFromNodes(
    subTree : ContextNodeCollection, 
    start : int, 
    length : int
)

매개 변수

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

설명

subTree에 WritingRegionNode의 하위 항목이 아닌 ContextNode가 들어 있으면 ArgumentException이 throw됩니다.

subTree에 연속되지 않은 여러 ContextNode 개체가 들어 있으면 모든 ContextNode 개체를 포함하는 가장 작은 텍스트 범위가 반환됩니다.

예제

다음 예제에서는 WritingRegionNode의 마지막 단락인 writingRegion을 찾습니다. 그런 다음 이 단락에 해당하는 텍스트 범위를 찾고, GetRecognizedString 값을 TextBox인 selectedResultsTextBox에 배치한 후 마지막 단락에 해당하는 텍스트를 선택합니다.

Dim paragraphs As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Paragraph)
Dim lastParagraph As ParagraphNode = Nothing
Dim maxY As Integer = Integer.MinValue
Dim paragraph As ParagraphNode
For Each paragraph In paragraphs
    If paragraph.Location.GetBounds().Bottom > maxY Then
        maxY = paragraph.Location.GetBounds().Bottom
        lastParagraph = paragraph
    End If
Next paragraph

If lastParagraph Is Nothing Then
    Return
End If
' Create a collection to hold this line
Dim lastParagraphCollection As New ContextNodeCollection(theInkAnalyzer)
lastParagraphCollection.Add(lastParagraph)

' Find corresponding start and length
Dim start, length As Integer
writingRegion.GetTextRangeFromNodes(lastParagraphCollection, start, length)

' Select this in the text box
selectedResultsTextBox.Text = writingRegion.GetRecognizedString()
selectedResultsTextBox.Select(start, length)
                ContextNodeCollection paragraphs =
                     theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Paragraph);
                ParagraphNode lastParagraph = null;
                int maxY = int.MinValue;
                foreach (ParagraphNode paragraph in paragraphs)
                {
                    if (paragraph.Location.GetBounds().Bottom > maxY)
                    {
                        maxY = paragraph.Location.GetBounds().Bottom;
                        lastParagraph = paragraph;
                    }
                }

                if (lastParagraph == null)
                    return;

                // Create a collection to hold this line
                ContextNodeCollection lastParagraphCollection = new ContextNodeCollection(theInkAnalyzer);
                lastParagraphCollection.Add(lastParagraph);

                // Find corresponding start and length
                int start, length;
                writingRegion.GetTextRangeFromNodes(lastParagraphCollection, out start, out length);

                // Select this in the text box
                selectedResultsTextBox.Text = writingRegion.GetRecognizedString();
                selectedResultsTextBox.Select(start, length);

플랫폼

Windows Vista

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

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

WritingRegionNode 클래스

WritingRegionNode 멤버

Microsoft.Ink 네임스페이스