Compartir vía


TextFormatter.FormatMinMaxParagraphWidth Método

Definición

Devuelve un valor que representa el ancho de párrafo más pequeño y más grande posible que puede contener completamente el contenido de texto especificado.

Sobrecargas

Nombre Description
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Devuelve un valor que representa el ancho de párrafo más pequeño y más grande posible que puede contener completamente el contenido de texto especificado.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Devuelve un valor que representa el ancho de párrafo más pequeño y más grande posible que puede contener completamente el contenido de texto especificado.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Devuelve un valor que representa el ancho de párrafo más pequeño y más grande posible que puede contener completamente 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 de la línea.

firstCharIndex
Int32

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

paragraphProperties
TextParagraphProperties

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

Devoluciones

Valor MinMaxParagraphWidth que representa el ancho de párrafo más pequeño y más grande posible que puede contener completamente 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 mínimo del párrafo corresponde a la palabra que tiene el mayor ancho; en este caso, la palabra "salted". Observe que varias palabras pueden aparecer en la misma línea, siempre que el ancho total no supere el ancho mínimo del párrafo.

Formateador de texto con el 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 más pequeño y más grande posible que puede contener completamente 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 de la línea.

firstCharIndex
Int32

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

paragraphProperties
TextParagraphProperties

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

textRunCache
TextRunCache

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

Devoluciones

Valor MinMaxParagraphWidth que representa el ancho de párrafo más pequeño y más grande posible que puede contener completamente el contenido de texto especificado.

Se aplica a