TextSource.GetTextRun(Int32) 메서드

정의

지정된 TextRun 위치에서 시작하는 TextSource을 검색합니다.

public:
 abstract System::Windows::Media::TextFormatting::TextRun ^ GetTextRun(int textSourceCharacterIndex);
public abstract System.Windows.Media.TextFormatting.TextRun GetTextRun (int textSourceCharacterIndex);
abstract member GetTextRun : int -> System.Windows.Media.TextFormatting.TextRun
Public MustOverride Function GetTextRun (textSourceCharacterIndex As Integer) As TextRun

매개 변수

textSourceCharacterIndex
Int32

TextSource이 검색되는 위치의 TextRun에 문자 인덱스 위치를 지정합니다.

반환

TextRun

TextRun 또는 TextRun에서 파생된 개체를 나타내는 값입니다.

예제

다음 예제에서는 재정의 GetTextRun 메서드 구현 됩니다.

// Retrieve the next formatted text run for the text source.
public override TextRun GetTextRun(int textSourceCharacterIndex)
{
    // Determine whether the text source index is in bounds.
    if (textSourceCharacterIndex < 0)
    {
        throw new ArgumentOutOfRangeException("textSourceCharacterIndex", "Value must be greater than 0.");
    }

    // Determine whether the text source index has exceeded or equaled the text source length.
    if (textSourceCharacterIndex >= _text.Length)
    {
        // Return an end-of-paragraph indicator -- a TextEndOfParagraph object is a special type of text run.
        return new TextEndOfParagraph(1);
    }

    // Create and return a TextCharacters object, which is formatted according to
    // the current layout and rendering properties.
    if (textSourceCharacterIndex < _text.Length)
    {
        // The TextCharacters object is a special type of text run that contains formatted text.
        return new TextCharacters(
           _text,                                       // The text store
           textSourceCharacterIndex,                    // The text store index
           _text.Length - textSourceCharacterIndex,     // The text store length
           new CustomTextRunProperties());              // The layout and rendering properties
    }

    // Return an end-of-paragraph indicator if there is no more text source.
    return new TextEndOfParagraph(1);
}
' Retrieve the next formatted text run for the text source.
Public Overrides Function GetTextRun(ByVal textSourceCharacterIndex As Integer) As TextRun
    ' Determine whether the text source index is in bounds.
    If textSourceCharacterIndex < 0 Then
        Throw New ArgumentOutOfRangeException("textSourceCharacterIndex", "Value must be greater than 0.")
    End If

    ' Determine whether the text source index has exceeded or equaled the text source length.
    If textSourceCharacterIndex >= _text.Length Then
        ' Return an end-of-paragraph indicator -- a TextEndOfParagraph object is a special type of text run.
        Return New TextEndOfParagraph(1)
    End If

    ' Create and return a TextCharacters object, which is formatted according to
    ' the current layout and rendering properties.
    If textSourceCharacterIndex < _text.Length Then
        ' The TextCharacters object is a special type of text run that contains formatted text.
        Return New TextCharacters(_text, textSourceCharacterIndex, _text.Length - textSourceCharacterIndex, New CustomTextRunProperties()) ' The layout and rendering properties -  The text store length -  The text store index -  The text store
    End If

    ' Return an end-of-paragraph indicator if there is no more text source.
    Return New TextEndOfParagraph(1)
End Function

설명

텍스트 실행을 단일 속성 집합을 공유 하는 문자 시퀀스입니다. 글꼴 패밀리, 글꼴 스타일, 전경색, 텍스트 장식 또는 기타 서식 지정 효과 텍스트 런 나누기와 같은 형식으로 변경 합니다. 합니다 TextRun 클래스에서 처리 하는 텍스트 내용의 몇 가지 형식을 나타내는 형식 계층 구조의 루트인 TextFormatter합니다. 각 클래스에서 파생 된 TextRun 텍스트 콘텐츠 고유 형식을 나타냅니다.

클래스 Description
TextRun 계층의 루트입니다. 동일한 문자 속성 집합을 공유 하는 문자 그룹을 정의 합니다.
TextCharacters 고유 실제 서체의 문자 모양 컬렉션을 정의 합니다.
TextEmbeddedObject 텍스트에 고유 엔터티로 수행 되는 측정, 적중 테스트 및 전체가 그리기 콘텐츠 형식을 정의 합니다. 이 콘텐츠 형식의 예에는 텍스트 선 가운데 있는 단추입니다.
TextEndOfLine 줄 바꿈 문자 코드를 정의 합니다.
TextEndOfParagraph 단락 나누기 문자 코드를 정의 합니다. TextEndOfLine에서 파생됩니다.
TextEndOfSegment 세그먼트 나누기 마커를 정의합니다.
TextHidden 보이지 않는 문자 범위를 정의합니다.
TextModifier 수정 범위의 시작을 정의 합니다.

적용 대상