TextPointer.GetTextInRun 메서드

정의

현재 TextPointer에 인접한 텍스트를 반환합니다.

오버로드

GetTextInRun(LogicalDirection)

지정된 논리 방향으로 현재 TextPointer에 인접한 텍스트를 포함하는 문자열을 반환합니다.

GetTextInRun(LogicalDirection, Char[], Int32, Int32)

지정된 방향으로 인접한 텍스트에서 지정된 최대 수의 문자를 호출자가 제공한 문자 배열에 복사합니다.

GetTextInRun(LogicalDirection)

지정된 논리 방향으로 현재 TextPointer에 인접한 텍스트를 포함하는 문자열을 반환합니다.

public:
 System::String ^ GetTextInRun(System::Windows::Documents::LogicalDirection direction);
public string GetTextInRun (System.Windows.Documents.LogicalDirection direction);
member this.GetTextInRun : System.Windows.Documents.LogicalDirection -> string
Public Function GetTextInRun (direction As LogicalDirection) As String

매개 변수

direction
LogicalDirection

인접한 텍스트를 찾아 반환할 논리 방향을 지정하는 LogicalDirection 값 중 하나입니다.

반환

지정된 논리 방향으로 인접한 텍스트를 포함하는 문자열입니다. 인접한 텍스트를 찾을 수 없는 경우 Empty입니다.

예제

다음 예제는이 메서드의 사용 방법을 보여 줍니다. 이 예제에서는 사용 된 GetTextInRun 간단한 텍스트 추출기를 구현 하는 방법입니다. 메서드는 지정 된 두 까지의 모든 텍스트의 문자열을 연결을 반환 TextPointer 인스턴스.

이 예제에서는 두 텍스트를 추출할 사용할 수 있지만 TextPointer 인스턴스 설명 목적 으로만, 것 하 고 프로덕션 코드에서는 사용할 수 없습니다. 대신 TextRange.Text 속성을 사용하세요.

// Returns a string containing the text content between two specified TextPointers.
string GetTextBetweenTextPointers(TextPointer start, TextPointer end)
{
    StringBuilder buffer = new StringBuilder();
 
    while (start != null && start.CompareTo(end) < 0)
    {
        if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
            buffer.Append(start.GetTextInRun(LogicalDirection.Forward));
 
        // Note that when the TextPointer points into a text run, this skips over the entire
        // run, not just the current character in the run.
        start = start.GetNextContextPosition(LogicalDirection.Forward);
    }
    return buffer.ToString();
} // End GetTextBetweenPointers.
' Returns a string containing the text content between two specified TextPointers.
Private Function GetTextBetweenTextPointers(ByVal start As TextPointer, ByVal [end] As TextPointer) As String
    Dim buffer As New StringBuilder()

    Do While start IsNot Nothing AndAlso start.CompareTo([end]) < 0
        If start.GetPointerContext(LogicalDirection.Forward) = TextPointerContext.Text Then
            buffer.Append(start.GetTextInRun(LogicalDirection.Forward))
        End If

        ' Note that when the TextPointer points into a text run, this skips over the entire
        ' run, not just the current character in the run.
        start = start.GetNextContextPosition(LogicalDirection.Forward)
    Loop
    Return buffer.ToString()

End Function ' End GetTextBetweenPointers.

설명

이 메서드는 텍스트의 중단 없이 실행만를 반환합니다. 아무 것도 반환 형식 이외의 기호 있는 경우 Text 현재 인접 한 TextPointer 지정 된 방향에서입니다. 마찬가지로 텍스트는 텍스트가 아닌 다음 기호 까지만 반환 됩니다.

추가 정보

적용 대상

GetTextInRun(LogicalDirection, Char[], Int32, Int32)

지정된 방향으로 인접한 텍스트에서 지정된 최대 수의 문자를 호출자가 제공한 문자 배열에 복사합니다.

public:
 int GetTextInRun(System::Windows::Documents::LogicalDirection direction, cli::array <char> ^ textBuffer, int startIndex, int count);
public int GetTextInRun (System.Windows.Documents.LogicalDirection direction, char[] textBuffer, int startIndex, int count);
member this.GetTextInRun : System.Windows.Documents.LogicalDirection * char[] * int * int -> int
Public Function GetTextInRun (direction As LogicalDirection, textBuffer As Char(), startIndex As Integer, count As Integer) As Integer

매개 변수

direction
LogicalDirection

인접한 텍스트를 찾아 복사할 논리 방향을 지정하는 LogicalDirection 값 중 하나입니다.

textBuffer
Char[]

텍스트를 복사할 버퍼입니다.

startIndex
Int32

복사된 텍스트를 쓰기 시작할 textBuffer에 대한 인덱스입니다.

count
Int32

복사할 최대 문자 수입니다.

반환

textBuffer에 실제로 복사되는 문자 수입니다.

예외

startIndex가 0보다 작거나 textBufferLength 속성보다 큰 경우.

또는

count가 0보다 작거나 의 나머지 공간 textBuffer 보다 큽니다(textBufferLength빼기startIndex).

설명

이 메서드는 텍스트의 중단 없이 실행만를 반환합니다. 아무 것도 반환 형식 이외의 기호 있는 경우 Text 현재 인접 한 TextPointer 지정 된 방향에서입니다. 마찬가지로 텍스트는 텍스트가 아닌 다음 기호 까지만 반환 됩니다.

추가 정보

적용 대상