TextRun Classe

Definizione

Rappresenta una sequenza di caratteri che condivide un unico insieme di proprietà.

public ref class TextRun abstract
public abstract class TextRun
type TextRun = class
Public MustInherit Class TextRun
Ereditarietà
TextRun
Derivato

Esempio

Nell'esempio seguente viene implementato un override per il GetTextRun metodo .

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

Commenti

Una sequenza di testo è una sequenza di caratteri che condividono un singolo set di proprietà. Qualsiasi modifica apportata al formato, ad esempio lo stile del carattere, il colore di primo piano, la famiglia di caratteri o qualsiasi altro effetto di formattazione, interrompe l'esecuzione del testo. Nell'esempio seguente viene illustrato come le modifiche apportate alla formattazione in una stringa di testo generano una serie di esecuzioni di testo. Ogni esecuzione di testo ha un set comune di proprietà di formattazione.

La TextRun classe è la radice di una gerarchia di tipi che rappresenta diversi tipi di contenuto di testo elaborato da TextFormatter. Ogni classe derivata da TextRun rappresenta un tipo distinto di contenuto di testo.

Class Descrizione
TextRun Radice della gerarchia. Definisce un gruppo di caratteri che condividono lo stesso set di proprietà di caratteri.
TextCharacters Definisce una raccolta di glifi di caratteri da un carattere tipografico fisico distinto.
TextEmbeddedObject Definisce un tipo di contenuto di testo in cui la misurazione, l'hit testing e il disegno dell'intero contenuto vengono eseguiti come entità distinta. Un esempio di questo tipo di contenuto è un pulsante al centro della riga di testo.
TextEndOfLine Definisce un codice carattere di interruzione di riga.
TextEndOfParagraph Definisce un codice carattere di interruzione di paragrafo. Classe derivata da TextEndOfLine.
TextEndOfSegment Definisce un marcatore di interruzione del segmento.
TextHidden Definisce un intervallo di caratteri non visibili.
TextModifier Definisce l'inizio di un ambito di modifica.

Costruttori

TextRun()

Crea un'istanza di un oggetto TextRun.

Proprietà

CharacterBufferReference

Ottiene un riferimento al buffer della sequenza di caratteri.

Length

Ottiene il numero di caratteri contenuti nella sequenza di caratteri.

Properties

Ottiene l'insieme delle proprietà di testo condivise da ogni carattere nella sequenza, ad esempio il carattere tipografico o il pennello di primo piano.

Metodi

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a

Vedi anche