TextSource.GetTextRun(Int32) Methode

Definitie

Hiermee haalt u een TextRun begin op een opgegeven TextSource positie op.

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

Parameters

textSourceCharacterIndex
Int32

Hiermee geeft u de positie van de tekenindex op in de TextSource plaats waar de TextRun wordt opgehaald.

Retouren

Een waarde die een TextRunof een object vertegenwoordigt dat is afgeleid van TextRun.

Voorbeelden

In het volgende voorbeeld wordt een onderdrukking voor de GetTextRun methode geïmplementeerd.

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

Opmerkingen

Een tekstuitvoering is een reeks tekens die één eigenschappenset delen. Elke wijziging in de opmaak, zoals lettertypefamilie, tekenstijl, voorgrondkleur, tekstdecoratie of een ander opmaakeffect, breekt de tekstuitvoering af. De TextRun klasse is de hoofdmap van een typehiërarchie die verschillende typen tekstinhoud vertegenwoordigt die door TextFormatter. Elke klasse die is afgeleid van TextRun , vertegenwoordigt een uniek type tekstinhoud.

Class Beschrijving
TextRun Hoofdmap van de hiërarchie. Hiermee definieert u een groep tekens die dezelfde set tekeneigenschappen delen.
TextCharacters Hiermee definieert u een verzameling tekenglyphs van een afzonderlijk fysiek lettertype.
TextEmbeddedObject Definieert een type tekstinhoud waarin het meten, het testen van treffers en het tekenen van de volledige inhoud wordt uitgevoerd als een afzonderlijke entiteit. Een voorbeeld van dit type inhoud is een knop in het midden van de tekstregel.
TextEndOfLine Definieert een regeleindetekencode.
TextEndOfParagraph Hiermee definieert u een code voor alinea-eindetekens. Is afgeleid van TextEndOfLine.
TextEndOfSegment Hiermee definieert u een segmenteindemarkering.
TextHidden Hiermee definieert u een bereik van niet-zichtbare tekens.
TextModifier Definieert het begin van een wijzigingsbereik.

Van toepassing op