Sdílet prostřednictvím


TextFormatter.FormatMinMaxParagraphWidth Metoda

Definice

Vrátí hodnotu, která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

Přetížení

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Vrátí hodnotu, která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Vrátí hodnotu, která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Vrátí hodnotu, která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

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

Parametry

textSource
TextSource

Objekt TextSource , který představuje zdroj textu řádku.

firstCharIndex
Int32

Hodnota Int32 , která určuje index znaků počátečního znaku na řádku.

paragraphProperties
TextParagraphProperties

Objekt TextParagraphProperties , který představuje vlastnosti odstavce, jako je směr toku, zarovnání nebo odsazení.

Návraty

MinMaxParagraphWidth

Hodnota MinMaxParagraphWidth , která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

Příklady

Následující příklad ukazuje, jak pomocí FormatMinMaxParagraphWidth metody vygenerovat minimální šířku odstavce pro formátované řádky textu.

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

Poznámky

Následující text používá minimální šířku odstavce pro zdrojový text, který se zobrazí jako více řádků. Minimální šířka odstavce odpovídá slovu, které má největší šířku – v tomto případě slovo "jumped". Všimněte si, že na stejném řádku se může zobrazit více slov, pokud celková šířka nepřekračuje minimální šířku odstavce.

Text Formatter using the minimum paragraph width
Minimální šířka odstavce

Platí pro

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Vrátí hodnotu, která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

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

Parametry

textSource
TextSource

Objekt TextSource , který představuje zdroj textu řádku.

firstCharIndex
Int32

Hodnota Int32 , která určuje index znaků počátečního znaku na řádku.

paragraphProperties
TextParagraphProperties

Objekt TextParagraphProperties , který představuje vlastnosti odstavce, jako je směr toku, zarovnání nebo odsazení.

textRunCache
TextRunCache

Objekt TextRunCache , který představuje mechanismus ukládání do mezipaměti pro rozložení textu.

Návraty

MinMaxParagraphWidth

Hodnota MinMaxParagraphWidth , která představuje nejmenší a největší možnou šířku odstavce, která může plně obsahovat zadaný textový obsah.

Platí pro