FormattedText.BuildHighlightGeometry メソッド

定義

書式設定されたテキストの強調表示境界ボックスを表す Geometry オブジェクトを返します。

オーバーロード

BuildHighlightGeometry(Point)

書式設定されたテキストの強調表示境界ボックスを表す Geometry オブジェクトを返します。

BuildHighlightGeometry(Point, Int32, Int32)

書式設定されたテキストに含まれる指定した部分文字列の強調表示境界ボックスを表す Geometry オブジェクトを返します。

BuildHighlightGeometry(Point)

書式設定されたテキストの強調表示境界ボックスを表す Geometry オブジェクトを返します。

public:
 System::Windows::Media::Geometry ^ BuildHighlightGeometry(System::Windows::Point origin);
public System.Windows.Media.Geometry BuildHighlightGeometry (System.Windows.Point origin);
member this.BuildHighlightGeometry : System.Windows.Point -> System.Windows.Media.Geometry
Public Function BuildHighlightGeometry (origin As Point) As Geometry

パラメーター

origin
Point

強調表示領域の原点。

戻り値

Geometry

書式設定されたテキストの強調表示境界ボックスを表す Geometry オブジェクト。

次の例は、オブジェクトを作成 FormattedText し、書式設定されたテキストとその境界ボックスのジオメトリを取得する方法を示しています。

/// <summary>
/// Create the outline geometry based on the formatted text.
/// </summary>
public void CreateText()
{
    System.Windows.FontStyle fontStyle = FontStyles.Normal;
    FontWeight fontWeight = FontWeights.Medium;

    if (Bold == true) fontWeight = FontWeights.Bold;
    if (Italic == true) fontStyle = FontStyles.Italic;

    // Create the formatted text based on the properties set.
    FormattedText formattedText = new FormattedText(
        Text,
        CultureInfo.GetCultureInfo("en-us"),
        FlowDirection.LeftToRight,
        new Typeface(
            Font,
            fontStyle,
            fontWeight,
            FontStretches.Normal),
        FontSize,
        System.Windows.Media.Brushes.Black // This brush does not matter since we use the geometry of the text. 
        );

    // Build the geometry object that represents the text.
    _textGeometry = formattedText.BuildGeometry(new System.Windows.Point(0, 0));

    // Build the geometry object that represents the text highlight.
    if (Highlight == true)
    {
        _textHighLightGeometry = formattedText.BuildHighlightGeometry(new System.Windows.Point(0, 0));
    }
}
''' <summary>
''' Create the outline geometry based on the formatted text.
''' </summary>
Public Sub CreateText()
    Dim fontStyle As FontStyle = FontStyles.Normal
    Dim fontWeight As FontWeight = FontWeights.Medium

    If Bold = True Then
        fontWeight = FontWeights.Bold
    End If
    If Italic = True Then
        fontStyle = FontStyles.Italic
    End If

    ' Create the formatted text based on the properties set.
    Dim formattedText As New FormattedText(Text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, New Typeface(Font, fontStyle, fontWeight, FontStretches.Normal), FontSize, Brushes.Black) ' This brush does not matter since we use the geometry of the text.

    ' Build the geometry object that represents the text.
    _textGeometry = formattedText.BuildGeometry(New Point(0, 0))

    ' Build the geometry object that represents the text highlight.
    If Highlight = True Then
        _textHighLightGeometry = formattedText.BuildHighlightGeometry(New Point(0, 0))
    End If
End Sub

注釈

境界ボックス領域には、指定した origin位置から始まる書式設定されたテキスト領域全体が含まれます。 返される Geometry オブジェクトには、強調表示されたテキストの境界ボックスのみが含まれており、レンダリングされたテキストは含まれません。

次の例は、変換されたテキストのストロークと強調表示を変更して視覚効果を作成する方法を示しています。

ストロークに画像ブラシを適用したテキスト ストロークとハイライトに適用されるイメージ ブラシの例

適用対象

BuildHighlightGeometry(Point, Int32, Int32)

書式設定されたテキストに含まれる指定した部分文字列の強調表示境界ボックスを表す Geometry オブジェクトを返します。

public:
 System::Windows::Media::Geometry ^ BuildHighlightGeometry(System::Windows::Point origin, int startIndex, int count);
public System.Windows.Media.Geometry BuildHighlightGeometry (System.Windows.Point origin, int startIndex, int count);
member this.BuildHighlightGeometry : System.Windows.Point * int * int -> System.Windows.Media.Geometry
Public Function BuildHighlightGeometry (origin As Point, startIndex As Integer, count As Integer) As Geometry

パラメーター

origin
Point

強調表示領域の原点。

startIndex
Int32

強調表示の境界の対象となる最初の文字のインデックス。

count
Int32

強調表示の境界に含める文字の数。

戻り値

Geometry

書式設定されたテキストの部分文字列の強調表示境界ボックスを表す Geometry オブジェクト。

注釈

返される Geometry オブジェクトには、強調表示されたテキストの境界ボックスのみが含まれており、レンダリングされたテキストは含まれません。

適用対象