Bagikan melalui


FormattedText.BuildHighlightGeometry Metode

Definisi

Mengembalikan Geometry objek yang mewakili kotak pembatas sorotan dari teks yang diformat.

Overload

BuildHighlightGeometry(Point)

Mengembalikan Geometry objek yang mewakili kotak pembatas sorotan dari teks yang diformat.

BuildHighlightGeometry(Point, Int32, Int32)

Mengembalikan Geometry objek yang mewakili kotak pembatas sorotan untuk substring tertentu dari teks yang diformat.

BuildHighlightGeometry(Point)

Mengembalikan Geometry objek yang mewakili kotak pembatas sorotan dari teks yang diformat.

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

Parameter

origin
Point

Asal wilayah sorotan.

Mengembalikan

Objek Geometry yang mewakili kotak batas sorotan dari teks yang diformat.

Contoh

Contoh berikut menunjukkan cara membuat FormattedText objek dan mengambil geometri teks yang diformat dan kotak pembatasnya.

/// <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

Keterangan

Wilayah kotak pembatas berisi seluruh area teks yang diformat mulai dari titik yang ditentukan oleh origin. Objek yang dikembalikan Geometry hanya berisi kotak batas teks yang disorot dan tidak berisi teks yang dirender.

Contoh berikut menggambarkan cara untuk membuat efek visual dengan memodifikasi goresan dan sorotan teks yang dikonversi.

Teks dengan kuas gambar diterapkan untuk membelai Contoh kuas gambar yang diterapkan pada goresan dan sorotan

Berlaku untuk

BuildHighlightGeometry(Point, Int32, Int32)

Mengembalikan Geometry objek yang mewakili kotak pembatas sorotan untuk substring tertentu dari teks yang diformat.

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

Parameter

origin
Point

Asal wilayah sorotan.

startIndex
Int32

Indeks karakter awal batas sorotan harus diperoleh.

count
Int32

Jumlah karakter yang harus dimuat batas sorotan.

Mengembalikan

Objek Geometry yang mewakili kotak batas sorotan dari substring teks yang diformat.

Keterangan

Objek yang dikembalikan Geometry hanya berisi kotak batas teks yang disorot dan tidak berisi teks yang dirender.

Berlaku untuk