Språk

TextFormatter.FormatMinMaxParagraphWidth Metod

Definition

Returnerar ett värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

Överlagringar

Name Description
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Returnerar ett värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Returnerar ett värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)

Returnerar ett värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

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

Parametrar

textSource
TextSource

Ett TextSource objekt som representerar textkällan för raden.

firstCharIndex
Int32

Ett Int32 värde som anger teckenindexet för starttecknet på raden.

paragraphProperties
TextParagraphProperties

Ett TextParagraphProperties objekt som representerar styckeegenskaper, till exempel flödesriktning, justering eller indrag.

Returer

Ett MinMaxParagraphWidth värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

Exempel

I följande exempel visas hur du använder FormatMinMaxParagraphWidth metoden för att generera minsta styckebredd för de formaterade textraderna.

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

Kommentarer

I följande text används den minsta styckebredden för källtexten, som visas som flera rader. Den minsta styckebredden motsvarar det ord som har störst bredd – i det här fallet ordet "hoppade". Observera att flera ord kan visas på samma rad, så länge den totala bredden inte överskrider den minsta styckebredden.

Textformaterare med minsta styckebredd Minsta styckebredd

Gäller för

FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache)

Returnerar ett värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

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

Parametrar

textSource
TextSource

Ett TextSource objekt som representerar textkällan för raden.

firstCharIndex
Int32

Ett Int32 värde som anger teckenindexet för starttecknet på raden.

paragraphProperties
TextParagraphProperties

Ett TextParagraphProperties objekt som representerar styckeegenskaper, till exempel flödesriktning, justering eller indrag.

textRunCache
TextRunCache

Ett TextRunCache objekt som representerar cachelagringsmekanismen för textlayouten.

Returer

Ett MinMaxParagraphWidth värde som representerar den minsta och största möjliga styckebredden som helt kan innehålla det angivna textinnehållet.

Gäller för