TextSource.GetTextRun(Int32) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 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값입니다.
예제
다음 예제에서는 메서드에 대한 재정의가 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 | 수정 범위의 시작을 정의합니다. |