Share via


TextFormatter.FormatMinMaxParagraphWidth Méthode

Définition

Retourne une valeur qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

Surcharges

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Retourne une valeur qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Retourne une valeur qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Retourne une valeur qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

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

Paramètres

textSource
TextSource

Objet TextSource qui représente la source de texte pour la ligne.

firstCharIndex
Int32

Valeur Int32 qui spécifie l'index de caractère du caractère initial de la ligne.

paragraphProperties
TextParagraphProperties

Objet TextParagraphProperties qui représente les propriétés de paragraphe, telles que le sens du déroulement, l'alignement ou la mise en retrait.

Retours

MinMaxParagraphWidth

Valeur MinMaxParagraphWidth qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

Exemples

L’exemple suivant montre comment utiliser la FormatMinMaxParagraphWidth méthode pour générer la largeur minimale du paragraphe pour les lignes de texte mises en forme.

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

Remarques

Le texte suivant utilise la largeur minimale du paragraphe pour le texte source, qui s’affiche sous la forme de plusieurs lignes. La largeur minimale du paragraphe correspond au mot qui a la plus grande largeur , dans ce cas, le mot « sauté ». Notez que plusieurs mots peuvent apparaître sur la même ligne, tant que la largeur totale ne dépasse pas la largeur minimale du paragraphe.

Formateur de texte utilisant la largeur de paragraphe minimale
Largeur minimale des paragraphes

S’applique à

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Retourne une valeur qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

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

Paramètres

textSource
TextSource

Objet TextSource qui représente la source de texte pour la ligne.

firstCharIndex
Int32

Valeur Int32 qui spécifie l'index de caractère du caractère initial de la ligne.

paragraphProperties
TextParagraphProperties

Objet TextParagraphProperties qui représente les propriétés de paragraphe, telles que le sens du déroulement, l'alignement ou la mise en retrait.

textRunCache
TextRunCache

Objet TextRunCache qui représente le mécanisme de mise en cache pour la disposition du texte.

Retours

MinMaxParagraphWidth

Valeur MinMaxParagraphWidth qui représente la largeur de paragraphe la plus petite et la plus grande possible pouvant contenir entièrement le contenu de texte spécifié.

S’applique à