FormattedText.BuildHighlightGeometry Método

Definição

Devolve um Geometry objeto que representa a caixa delimitadora de destaque do texto formatado.

Sobrecargas

Name Description
BuildHighlightGeometry(Point)

Devolve um Geometry objeto que representa a caixa delimitadora de destaque do texto formatado.

BuildHighlightGeometry(Point, Int32, Int32)

Devolve um Geometry objeto que representa a caixa delimitadora de destaque para uma substring especificada do texto formatado.

BuildHighlightGeometry(Point)

Devolve um Geometry objeto que representa a caixa delimitadora de destaque 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 destaque.

Devoluções

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

Exemplos

O exemplo seguinte mostra como criar um FormattedText objeto e recuperar as geometrias do texto formatado e da 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) fontWeight = FontWeights.Bold;
    if (Italic) 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)
    {
        _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

Observações

A região da caixa delimitadora contém toda a área de texto formatada a partir do ponto especificado por origin. O objeto devolvido Geometry contém apenas a caixa delimitadora do texto destacado e não contém qualquer texto renderizado.

O exemplo seguinte ilustra uma forma de criar efeitos visuais modificando o traço e o destaque do texto convertido.

Texto com pincel de imagem aplicado ao traçado

Aplica-se a

BuildHighlightGeometry(Point, Int32, Int32)

Devolve um Geometry objeto que representa a caixa delimitadora de destaque para uma substring 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 destaque.

startIndex
Int32

O índice do carácter inicial para o qual os limites de destaque devem ser obtidos.

count
Int32

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

Devoluções

O Geometry objeto que representa a caixa delimitadora de destaque da substring de texto formatada.

Observações

O objeto devolvido Geometry contém apenas a caixa delimitadora do texto destacado e não contém qualquer texto renderizado.

Aplica-se a