TextRun Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Representa uma sequência de caracteres que partilham um único conjunto de propriedades.
public ref class TextRun abstract
public abstract class TextRun
type TextRun = class
Public MustInherit Class TextRun
- Herança
-
TextRun
- Derivado
Exemplos
No exemplo seguinte, é implementada uma substituição para o 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
Observações
Uma execução de texto é uma sequência de caracteres que partilham um único conjunto de propriedades. Qualquer alteração ao formato, como estilo de fonte, cor em primeiro plano, família de fontes ou qualquer outro efeito de formatação, interrompe a execução do texto. O exemplo seguinte ilustra como alterações na formatação de uma cadeia de texto resultam numa série de sequências de texto – cada execução de texto tem um conjunto comum de propriedades de formatação.
A TextRun classe é a raiz de uma hierarquia de tipos que representa vários tipos de conteúdo textual processado por TextFormatter. Cada classe derivada representa TextRun um tipo distinto de conteúdo textual.
| Classe | Descrição |
|---|---|
| TextRun | Raiz da hierarquia. Define um grupo de caracteres que partilham o mesmo conjunto de propriedades de caracteres. |
| TextCharacters | Define uma coleção de glifos de carácter a partir de uma tipografia física distinta. |
| TextEmbeddedObject | Define um tipo de conteúdo textual em que a medição, o teste de acertos e o desenho de todo o conteúdo são feitos como uma entidade distinta. Um exemplo deste tipo de conteúdo é um botão no meio da linha de texto. |
| TextEndOfLine | Define um código de carácter de quebra de linha. |
| TextEndOfParagraph | Define um código de carácter de quebra de parágrafo. Deriva de TextEndOfLine. |
| TextEndOfSegment | Define um marcador de quebra de segmento. |
| TextHidden | Define um conjunto de caracteres invisíveis. |
| TextModifier | Define o início de um âmbito de modificação. |
Construtores
| Name | Description |
|---|---|
| TextRun() |
Cria uma instância de um TextRun objeto. |
Propriedades
| Name | Description |
|---|---|
| CharacterBufferReference |
Obtém uma referência ao buffer de caracteres de execução de texto. |
| Length |
Obtém o número de caracteres na sequência de texto. |
| Properties |
Obtém o conjunto de propriedades de texto que são partilhadas por cada carácter na sequência de texto, como tipografia ou pincel de primeiro plano. |
Métodos
| Name | Description |
|---|---|
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| GetHashCode() |
Serve como função de hash predefinida. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |