Compartilhar via


FormattedText.BuildHighlightGeometry Método

Definição

Retorna um objeto Geometry que representa a caixa delimitadora de realce do texto formatado.

Sobrecargas

BuildHighlightGeometry(Point)

Retorna um objeto Geometry que representa a caixa delimitadora de realce do texto formatado.

BuildHighlightGeometry(Point, Int32, Int32)

Retorna um objeto Geometry que representa a caixa delimitadora de realce para uma subcadeia de caracteres especificada do texto formatado.

BuildHighlightGeometry(Point)

Retorna um objeto Geometry que representa a caixa delimitadora de realce do texto formatado.

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

Parâmetros

origin
Point

A origem da região de realce.

Retornos

Geometry

O objeto Geometry que representa a caixa delimitadora de realce do texto formatado.

Exemplos

O exemplo a seguir mostra como criar um FormattedText objeto e recuperar as geometrias do texto formatado e sua caixa delimitadora.

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

Comentários

A região da caixa delimitadora contém toda a área de texto formatada começando no ponto especificado por origin. O objeto retornado Geometry contém apenas a caixa delimitadora do texto realçado e não contém nenhum texto renderizado.

O exemplo a seguir ilustra uma maneira de criar efeitos visuais modificando o traço e realce do texto convertido.

Texto com pincel de imagem aplicado ao traço Exemplo de um pincel de imagem aplicado ao traço e realce

Aplica-se a

BuildHighlightGeometry(Point, Int32, Int32)

Retorna um objeto Geometry que representa a caixa delimitadora de realce para uma subcadeia de caracteres especificada do texto formatado.

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

Parâmetros

origin
Point

A origem da região de realce.

startIndex
Int32

O índice do caractere inicial para o qual os limites do realce devem ser obtidos.

count
Int32

O número de caracteres que os limites do realce devem conter.

Retornos

Geometry

O objeto Geometry que representa a caixa delimitadora de realce da subcadeia de caracteres do texto formatado.

Comentários

O objeto retornado Geometry contém apenas a caixa delimitadora do texto realçado e não contém nenhum texto renderizado.

Aplica-se a