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 개체는 강조 표시된 텍스트의 경계 상자만 포함하며 렌더링된 텍스트는 포함하지 않습니다.

적용 대상