TextFormatter.FormatMinMaxParagraphWidth 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回值,代表可完整內含指定之文字內容的最小及最大可能段落的寬度。
多載
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties) |
傳回值,代表可完整內含指定之文字內容的最小及最大可能段落的寬度。 |
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, TextRunCache) |
傳回值,代表可完整內含指定之文字內容的最小及最大可能段落的寬度。 |
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties)
傳回值,代表可完整內含指定之文字內容的最小及最大可能段落的寬度。
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
參數
- textSource
- TextSource
TextSource 物件,表示行的文字來源。
- paragraphProperties
- TextParagraphProperties
TextParagraphProperties 物件,表示段落屬性,例如文字流向、對齊或縮排。
傳回
MinMaxParagraphWidth 值,表示可完整內含指定之文字內容的最小及最大可能段落的寬度。
範例
下列範例示範如何使用 FormatMinMaxParagraphWidth 方法來產生格式化文字行的最小段落寬度。
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
備註
下列文字會使用來源文字的最小段落寬度,以多行顯示。 段落寬度下限會對應至寬度最高的字組,在此案例中為「跳躍」一詞。 請注意,只要總寬度不超過段落寬度下限,多個單字可以出現在同一行。
段落寬度下限
適用於
FormatMinMaxParagraphWidth(TextSource, Int32, TextParagraphProperties, 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);
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
參數
- textSource
- TextSource
TextSource 物件,表示行的文字來源。
- paragraphProperties
- TextParagraphProperties
TextParagraphProperties 物件,表示段落屬性,例如文字流向、對齊或縮排。
- textRunCache
- TextRunCache
TextRunCache 物件,表示文字配置的快取機制。
傳回
MinMaxParagraphWidth 值,表示可完整內含指定之文字內容的最小及最大可能段落的寬度。