TextFormatter.FormatMinMaxParagraphWidth Método

Definición

Devuelve un valor que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido de texto especificado.

Sobrecargas

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Devuelve un valor que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido de texto especificado.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Devuelve un valor que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido de texto especificado.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Devuelve un valor que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido 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

Objeto TextSource que representa el origen de texto para la línea.

firstCharIndex
Int32

Valor Int32 que especifica el índice del carácter inicial de la línea.

paragraphProperties
TextParagraphProperties

Objeto TextParagraphProperties que representa las propiedades de párrafo, como dirección de flujo, alineación o sangría.

Devoluciones

MinMaxParagraphWidth

Valor MinMaxParagraphWidth que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido de texto especificado.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el FormatMinMaxParagraphWidth método para generar el ancho de párrafo mínimo para las líneas de texto con formato.

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

Comentarios

En el texto siguiente se usa el ancho de párrafo mínimo para el texto de origen, que se muestra como varias líneas. El ancho de párrafo mínimo corresponde a la palabra que tiene el mayor ancho; en este caso, la palabra "jumped". Observe que varias palabras pueden aparecer en la misma línea, siempre y cuando el ancho total no supere el ancho mínimo del párrafo.

Formateador de texto con ancho de párrafo mínimo
Ancho mínimo de párrafo

Se aplica a

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Devuelve un valor que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido 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

Objeto TextSource que representa el origen de texto para la línea.

firstCharIndex
Int32

Valor Int32 que especifica el índice del carácter inicial de la línea.

paragraphProperties
TextParagraphProperties

Objeto TextParagraphProperties que representa las propiedades de párrafo, como dirección de flujo, alineación o sangría.

textRunCache
TextRunCache

Objeto TextRunCache que representa el mecanismo de almacenamiento en caché para el diseño de texto.

Devoluciones

MinMaxParagraphWidth

Valor MinMaxParagraphWidth que representa el ancho de párrafo menor y mayor posible que puede incluir totalmente el contenido de texto especificado.

Se aplica a