Compartilhar via


TextFormatter.FormatMinMaxParagraphWidth Método

Definição

Retorna um valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

Sobrecargas

Nome Description
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Retorna um valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Retorna um valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Retorna um valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

public:
 abstract System::Windows::Media::TextFormatting::MinMaxParagraphWidth FormatMinMaxParagraphWidth(System::Windows::Media::TextFormatting::TextSource ^ textSource, int firstCharIndex, System::Windows::Media::TextFormatting::TextParagraphProperties ^ paragraphProperties);
public abstract System.Windows.Media.TextFormatting.MinMaxParagraphWidth FormatMinMaxParagraphWidth(System.Windows.Media.TextFormatting.TextSource textSource, int firstCharIndex, System.Windows.Media.TextFormatting.TextParagraphProperties paragraphProperties);
abstract member FormatMinMaxParagraphWidth : System.Windows.Media.TextFormatting.TextSource * int * System.Windows.Media.TextFormatting.TextParagraphProperties -> System.Windows.Media.TextFormatting.MinMaxParagraphWidth
Public MustOverride Function FormatMinMaxParagraphWidth (textSource As TextSource, firstCharIndex As Integer, paragraphProperties As TextParagraphProperties) As MinMaxParagraphWidth

Parâmetros

textSource
TextSource

Um TextSource objeto que representa a fonte de texto da linha.

firstCharIndex
Int32

Um Int32 valor que especifica o índice de caracteres do caractere inicial na linha.

paragraphProperties
TextParagraphProperties

Um TextParagraphProperties objeto que representa propriedades de parágrafo, como direção de fluxo, alinhamento ou recuo.

Retornos

Um MinMaxParagraphWidth valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

Exemplos

O exemplo a seguir mostra como usar o FormatMinMaxParagraphWidth método para gerar a largura mínima do parágrafo para as linhas de texto formatadas.

MinMaxParagraphWidth minMaxParaWidth =
    formatter.FormatMinMaxParagraphWidth(customTextSource, 0, customTextParagraphProperties);

// Format each line of text from the text store and draw it.
while (textStorePosition < customTextSource.Text.Length)
{
    // Create a textline from the text store using the TextFormatter object.
    using (TextLine myTextLine = formatter.FormatLine(
        customTextSource,
        textStorePosition,
        minMaxParaWidth.MinWidth,
        customTextParagraphProperties,
        null))
    {
        // Draw the formatted text into the drawing context.
        myTextLine.Draw(drawingContext, linePosition, InvertAxes.None);

        // Update the index position in the text store.
        textStorePosition += myTextLine.Length;

        // Update the line position coordinate for the displayed line.
        linePosition.Y += myTextLine.Height;
    }
}
Dim minMaxParaWidth As MinMaxParagraphWidth = formatter.FormatMinMaxParagraphWidth(customTextSource, 0, customTextParagraphProperties)

' Format each line of text from the text store and draw it.
Do While textStorePosition < customTextSource.Text.Length
    ' Create a textline from the text store using the TextFormatter object.
    Using myTextLine As TextLine = formatter.FormatLine(customTextSource, textStorePosition, minMaxParaWidth.MinWidth, customTextParagraphProperties, Nothing)
        ' Draw the formatted text into the drawing context.
        myTextLine.Draw(drawingContext, linePosition, InvertAxes.None)

        ' Update the index position in the text store.
        textStorePosition += myTextLine.Length

        ' Update the line position coordinate for the displayed line.
        linePosition.Y += myTextLine.Height
    End Using
Loop

Comentários

O texto a seguir usa a largura mínima do parágrafo para o texto de origem, que é exibido como várias linhas. A largura mínima do parágrafo corresponde à palavra que tem a maior largura - nesse caso, a palavra "saltou". Observe que várias palavras podem aparecer na mesma linha, desde que a largura total não exceda a largura mínima do parágrafo.

Formatador de Texto usando o Formatador de Texto de largura mínima Largura mínima do parágrafo

Aplica-se a

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Retorna um valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

public:
 abstract System::Windows::Media::TextFormatting::MinMaxParagraphWidth FormatMinMaxParagraphWidth(System::Windows::Media::TextFormatting::TextSource ^ textSource, int firstCharIndex, System::Windows::Media::TextFormatting::TextParagraphProperties ^ paragraphProperties, System::Windows::Media::TextFormatting::TextRunCache ^ textRunCache);
public abstract System.Windows.Media.TextFormatting.MinMaxParagraphWidth FormatMinMaxParagraphWidth(System.Windows.Media.TextFormatting.TextSource textSource, int firstCharIndex, System.Windows.Media.TextFormatting.TextParagraphProperties paragraphProperties, System.Windows.Media.TextFormatting.TextRunCache textRunCache);
abstract member FormatMinMaxParagraphWidth : System.Windows.Media.TextFormatting.TextSource * int * System.Windows.Media.TextFormatting.TextParagraphProperties * System.Windows.Media.TextFormatting.TextRunCache -> System.Windows.Media.TextFormatting.MinMaxParagraphWidth
Public MustOverride Function FormatMinMaxParagraphWidth (textSource As TextSource, firstCharIndex As Integer, paragraphProperties As TextParagraphProperties, textRunCache As TextRunCache) As MinMaxParagraphWidth

Parâmetros

textSource
TextSource

Um TextSource objeto que representa a fonte de texto da linha.

firstCharIndex
Int32

Um Int32 valor que especifica o índice de caracteres do caractere inicial na linha.

paragraphProperties
TextParagraphProperties

Um TextParagraphProperties objeto que representa propriedades de parágrafo, como direção de fluxo, alinhamento ou recuo.

textRunCache
TextRunCache

Um TextRunCache objeto que representa o mecanismo de cache para o layout do texto.

Retornos

Um MinMaxParagraphWidth valor que representa a menor e maior largura de parágrafo possível que pode conter totalmente o conteúdo de texto especificado.

Aplica-se a