TextRun Clase

Definición

Representa una secuencia de caracteres que comparten un único conjunto de propiedades.

public ref class TextRun abstract
public abstract class TextRun
type TextRun = class
Public MustInherit Class TextRun
Herencia
TextRun
Derivado

Ejemplos

En el ejemplo siguiente, se implementa una invalidación para el GetTextRun método .

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

Comentarios

Una ejecución de texto es una secuencia de caracteres que comparten un único conjunto de propiedades. Cualquier cambio en el formato, como el estilo de fuente, el color de primer plano, la familia de fuentes o cualquier otro efecto de formato, interrumpe la ejecución del texto. En el ejemplo siguiente se muestra cómo los cambios en el formato de una cadena de texto da como resultado una serie de ejecuciones de texto: cada ejecución de texto tiene un conjunto común de propiedades de formato.

La TextRun clase es la raíz de una jerarquía de tipos que representa varios tipos de contenido de texto procesado por TextFormatter. Cada clase que se deriva de TextRun representa un tipo distinto de contenido de texto.

Clase Descripción
TextRun Raíz de la jerarquía. Define un grupo de caracteres que comparten el mismo conjunto de propiedades de caracteres.
TextCharacters Define una colección de glifos de caracteres a partir de un tipo de letra físico distinto.
TextEmbeddedObject Define un tipo de contenido de texto en el que la medición, las pruebas de posicionamiento y el dibujo de todo el contenido se realiza como una entidad distinta. Un ejemplo de este tipo de contenido es un botón en medio de la línea de texto.
TextEndOfLine Define un código de carácter de salto de línea.
TextEndOfParagraph Define un código de carácter de salto de párrafo. Deriva de TextEndOfLine.
TextEndOfSegment Define un marcador de interrupción de segmento.
TextHidden Define un intervalo de caracteres no visibles.
TextModifier Define el principio de un ámbito de modificación.

Constructores

TextRun()

Crea una instancia de un objeto TextRun.

Propiedades

CharacterBufferReference

Obtiene una referencia al búfer de caracteres de ejecución de texto.

Length

Obtiene el número de caracteres de la ejecución de texto.

Properties

Obtiene el conjunto de propiedades de texto compartidas por cada carácter de la ejecución de texto, como tipo de letra o pincel de primer plano.

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a

Consulte también