TextSource.GetTextRun(Int32) Yöntem

Tanım

Belirtilen TextRun konumda bir TextSource başlangıç alır.

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

Parametreler

textSourceCharacterIndex
Int32

öğesinin alındığı konumdaki TextSource karakter dizini konumunu TextRun belirtir.

Döndürülenler

bir öğesini veya öğesinden TextRuntüretilmiş bir nesneyi temsil eden TextRunbir değer.

Örnekler

Aşağıdaki örnekte, yöntemi için GetTextRun bir geçersiz kılma uygulanır.

// 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

Açıklamalar

Metin çalıştırması, tek bir özellik kümesini paylaşan bir karakter dizisidir. Yazı tipi ailesi, yazı tipi stili, ön plan rengi, metin dekorasyonu veya başka bir biçimlendirme efekti gibi biçim değişiklikleri metin çalıştırmasını bozar. TextRun sınıfı, tarafından TextFormatterişlenen çeşitli metin içeriği türlerini temsil eden bir tür hiyerarşisinin köküdür. öğesinden TextRun türetilen her sınıf, ayrı bir metin içeriği türünü temsil eder.

Class Açıklama
TextRun Hiyerarşinin kökü. Aynı karakter özellikleri kümesini paylaşan bir karakter grubunu tanımlar.
TextCharacters Farklı bir fiziksel yazı tipinden karakter karakterleri koleksiyonunu tanımlar.
TextEmbeddedObject İçeriğin tamamının ölçülmesi, isabet testi ve çiziminin ayrı bir varlık olarak yapıldığı bir metin içeriği türünü tanımlar. Bu içerik türüne örnek olarak, metin satırının ortasındaki bir düğme yer alır.
TextEndOfLine Satır sonu karakter kodunu tanımlar.
TextEndOfParagraph Paragraf sonu karakter kodunu tanımlar. TextEndOfLine'den türetilir.
TextEndOfSegment Segment sonu işaretçisini tanımlar.
TextHidden Görünür olmayan karakter aralığını tanımlar.
TextModifier Değişiklik kapsamının başlangıcını tanımlar.

Şunlara uygulanır