다음을 통해 공유


InkAnalyzer.GetTextRangeFromNodes 메서드

업데이트: 2007년 11월

인식된 문자열에서 ContextNode 개체의 컬렉션에 해당하는 텍스트 범위를 찾습니다.

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

구문

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

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

매개 변수

  • start
    형식: System.Int32%
    이 메서드가 반환될 때 start 매개 변수에는 텍스트 범위의 시작 부분을 나타내는 부호 있는 32비트 정수가 포함됩니다. 이 매개 변수는 초기화되지 않은 상태로 전달됩니다.
  • length
    형식: System.Int32%
    이 메서드가 반환될 때 length 매개 변수에는 텍스트 범위의 길이를 나타내는 부호 있는 32비트 정수가 포함됩니다. 이 매개 변수는 초기화되지 않은 상태로 전달됩니다.

설명

nodesToSearch에 서로 인접하지 않은 여러 ContextNode개체가 들어 있으면 모든 ContextNode 개체를 포함하는 가장 작은 텍스트 범위가 반환됩니다.

nodesToSearch에 InkAnalyzer와 연결되지 않은 ContextNode가 들어 있으면 이 메서드에서 System.ArgumentException이 throw됩니다.

예제

이 예제에서는 System.Windows.Forms.TextBox인 theResultsTextBox의 텍스트를 InkAnalyzer인 theInkAnalyzer의 인식 문자열로 설정하는 SelectTextRangeFromNodes라는 메서드를 정의합니다. 그런 다음 텍스트 상자의 선택 영역을 theContextNodes 매개 변수에 대해 인식된 텍스트 범위로 설정합니다.

''' <summary>
''' Selects the text range in the TextBox, theResultsTextBox, that represents
''' the node ranges in theContextNodes.
''' </summary>
''' <param name="theContextNodes">
''' The nodes for which to select the text range.</param>
''' <remarks>
''' If <paramref name="theContextNodes"/> are not current context nodes
''' of the InkAnalyzer, theInkAnalyzer, then GetTextRangeFromNodes throws
''' an ArgumentException.
''' </remarks>
Private Sub SelectTextRangeFromNodes(ByVal theContextNodes As Microsoft.Ink.ContextNodeCollection)
    ' Set the text of theResultsTextBox.
    Me.theResultsTextBox.Text = Me.theInkAnalyzer.GetRecognizedString()

    ' Get the text range for theContextNodes.
    Dim theStart As Integer
    Dim theLength As Integer
    Try
        Me.theInkAnalyzer.GetTextRangeFromNodes( _
            theContextNodes, theStart, theLength)
        ' Check for common exceptions.
    Catch ex As ArgumentException
        Throw New ArgumentException( _
            "Invalid ContextNodeCollection", "theContextNodes", ex)
    End Try

    ' Select the text range in the TextBox.
    Me.theResultsTextBox.Select(theStart, theLength)
    Me.theResultsTextBox.Invalidate()

End Sub 'SelectTextRangeFromNodes
/// <summary>
/// Selects the text range in the TextBox, theResultsTextBox, that represents
/// the node ranges in theContextNodes.
/// </summary>
/// <param name="theContextNodes">
/// The nodes for which to select the text range.</param>
/// <remarks>
/// If <paramref name="theContextNodes"/> are not current context nodes
/// of the InkAnalyzer, theInkAnalyzer, then GetTextRangeFromNodes throws
/// an ArgumentException.
/// </remarks>
private void SelectTextRangeFromNodes(
    Microsoft.Ink.ContextNodeCollection theContextNodes)
{
    // Set the text of theResultsTextBox.
    this.theResultsTextBox.Text = this.theInkAnalyzer.GetRecognizedString();

    // Get the text range for theContextNodes.
    int theStart;
    int theLength;
    try
    {
        this.theInkAnalyzer.GetTextRangeFromNodes(
            theContextNodes, out theStart, out theLength);
    }
    // Check for common exceptions.
    catch (ArgumentException ex)
    {
        throw new ArgumentException("Invalid ContextNodeCollection",
            "theContextNodes", ex);
    }

    // Select the text range in the TextBox.
    this.theResultsTextBox.Select(theStart, theLength);
    this.theResultsTextBox.Invalidate();
}

플랫폼

Windows Vista

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

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

InkAnalyzer 클래스

InkAnalyzer 멤버

Microsoft.Ink 네임스페이스