Sdílet prostřednictvím


FormattedText.BuildHighlightGeometry Metoda

Definice

Geometry Vrátí objekt, který představuje ohraničující pole zvýraznění formátovaného textu.

Přetížení

BuildHighlightGeometry(Point)

Geometry Vrátí objekt, který představuje ohraničující pole zvýraznění formátovaného textu.

BuildHighlightGeometry(Point, Int32, Int32)

Geometry Vrátí objekt, který představuje ohraničující pole zvýraznění pro zadaný podřetěc formátovaného textu.

BuildHighlightGeometry(Point)

Geometry Vrátí objekt, který představuje ohraničující pole zvýraznění formátovaného textu.

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

Parametry

origin
Point

Původ oblasti zvýraznění

Návraty

Geometry

Objekt Geometry , který představuje zvýrazňující ohraničující pole formátovaného textu.

Příklady

Následující příklad ukazuje, jak vytvořit FormattedText objekt a načíst geometrie formátovaného textu a jeho ohraničujícího pole.

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

Poznámky

Oblast ohraničujícího rámečku obsahuje celou formátovanou oblast textu počínaje bodem určeným origin. Vrácený Geometry objekt obsahuje pouze ohraničující pole zvýrazněného textu a neobsahuje žádný vykreslený text.

Následující příklad ukazuje způsob, jak vytvořit vizuální efekty úpravou tahu a zvýraznění převedeného textu.

Text s štětcem obrázku použitým na tah Příklad štětce obrázku použitého na tah a zvýraznění

Platí pro

BuildHighlightGeometry(Point, Int32, Int32)

Geometry Vrátí objekt, který představuje ohraničující pole zvýraznění pro zadaný podřetěc formátovaného textu.

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

Parametry

origin
Point

Původ oblasti zvýraznění

startIndex
Int32

Index počátečního znaku, pro který by měly být získány hranice zvýraznění.

count
Int32

Počet znaků, které má ohraničení zvýraznění obsahovat.

Návraty

Geometry

Objekt Geometry , který představuje ohraničující pole zvýraznění podřetědce formátovaného textu.

Poznámky

Vrácený Geometry objekt obsahuje pouze ohraničující pole zvýrazněného textu a neobsahuje žádný vykreslený text.

Platí pro