TextRun Classe

Définition

Représente une séquence de caractères qui partagent le même ensemble de propriétés.

public ref class TextRun abstract
public abstract class TextRun
type TextRun = class
Public MustInherit Class TextRun
Héritage
TextRun
Dérivé

Exemples

Dans l’exemple suivant, un remplacement de la GetTextRun méthode est implémenté.

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

Remarques

Une exécution de texte est une séquence de caractères partageant un jeu de propriétés unique. Toute modification du format, tel que le style de police, la couleur de premier plan, la famille de polices ou tout autre effet de mise en forme, interrompt l’exécution du texte. L’exemple suivant montre comment les modifications apportées à la mise en forme d’une chaîne de texte entraînent une série d’exécutions de texte : chaque exécution de texte a un ensemble commun de propriétés de mise en forme.

La TextRun classe est la racine d’une hiérarchie de types représentant plusieurs types de contenu texte traités par TextFormatter. Chaque classe dérivée de TextRun représente un type distinct de contenu texte.

Classe Description
TextRun Racine de la hiérarchie. Définit un groupe de caractères qui partagent le même jeu de propriétés de caractères.
TextCharacters Définit une collection de glyphes de caractères à partir d’une police physique distincte.
TextEmbeddedObject Définit un type de contenu texte dans lequel la mesure, le test d’accès et le dessin de l’ensemble du contenu sont effectués en tant qu’entité distincte. Un exemple de ce type de contenu est un bouton au milieu de la ligne de texte.
TextEndOfLine Définit un code de caractère de saut de ligne.
TextEndOfParagraph Définit un code de caractère de saut de paragraphe. Dérive de TextEndOfLine.
TextEndOfSegment Définit un marqueur d’arrêt de segment.
TextHidden Définit une plage de caractères non visibles.
TextModifier Définit le début d’une étendue de modification.

Constructeurs

TextRun()

Crée une instance d'un objet TextRun.

Propriétés

CharacterBufferReference

Obtient une référence à la mémoire tampon où sont stockés les caractères de la séquence de texte.

Length

Obtient le nombre de caractères figurant dans la séquence de texte.

Properties

Obtient le jeu des propriétés textuelles partagées par tous les caractères figurant dans la séquence de texte, telles que la police ou le pinceau de premier plan.

Méthodes

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
ToString()

Retourne une chaîne qui représente l'objet actuel.

(Hérité de Object)

S’applique à

Voir aussi