TextRun Třída

Definice

Představuje posloupnost znaků, které sdílejí jednu sadu vlastností.

public ref class TextRun abstract
public abstract class TextRun
type TextRun = class
Public MustInherit Class TextRun
Dědičnost
TextRun
Odvozené

Příklady

V následujícím příkladu je implementováno přepsání metody 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

Poznámky

Spuštění textu je posloupnost znaků sdílejících jednu sadu vlastností. Jakákoli změna formátu, například styl písma, barva popředí, rodina písem nebo jakýkoli jiný efekt formátování, přeruší spuštění textu. Následující příklad ukazuje, jak se změny formátování textového řetězce projeví v řadě spuštění textu – každé spuštění textu má společnou sadu vlastností formátování.

Třída TextRun je kořenem hierarchie typů představující několik typů textového obsahu zpracovávaného TextFormatter. Každá třída odvozená z TextRun představuje odlišný typ textového obsahu.

Class Description
TextRun Kořen hierarchie Definuje skupinu znaků, které sdílejí stejnou sadu vlastností znaků.
TextCharacters Definuje kolekci znaků glyfů z odlišného fyzického typu.
TextEmbeddedObject Definuje typ textového obsahu, ve kterém se měření, testování hitů a kreslení celého obsahu provádí jako samostatná entita. Příkladem tohoto typu obsahu je tlačítko uprostřed řádku textu.
TextEndOfLine Definuje kód znaku konce řádku.
TextEndOfParagraph Definuje kód znaku konce odstavce. Odvozuje se z TextEndOfLine.
TextEndOfSegment Definuje značku konce segmentu.
TextHidden Definuje rozsah neviditelných znaků.
TextModifier Definuje začátek oboru úprav.

Konstruktory

Name Description
TextRun()

Vytvoří instanci objektu TextRun .

Vlastnosti

Name Description
CharacterBufferReference

Získá odkaz na vyrovnávací paměť znaků spuštění textu.

Length

Získá počet znaků ve spuštění textu.

Properties

Získá sadu vlastností textu, které jsou sdíleny každým znakem v textovém spuštění, jako je typ písma nebo štětce popředí.

Metody

Name Description
Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také