Share via


FormattedText.BuildHighlightGeometry Método

Definición

Devuelve un objeto Geometry que representa el rectángulo de selección del resaltado del texto con formato.

Sobrecargas

BuildHighlightGeometry(Point)

Devuelve un objeto Geometry que representa el rectángulo de selección del resaltado del texto con formato.

BuildHighlightGeometry(Point, Int32, Int32)

Devuelve un objeto Geometry que representa el rectángulo de selección del resaltado de la subcadena especificada del texto con formato.

BuildHighlightGeometry(Point)

Devuelve un objeto Geometry que representa el rectángulo de selección del resaltado del texto con formato.

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

Origen de la región de resaltado.

Devoluciones

Geometry

Objeto Geometry que representa el rectángulo de selección del resaltado del texto con formato.

Ejemplos

En el ejemplo siguiente se muestra cómo crear un FormattedText objeto y recuperar las geometrías del texto con formato y su cuadro de límite.

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

Comentarios

La región del rectángulo delimitador contiene todo el área de texto con formato que comienza en el punto especificado por origin. El objeto devuelto Geometry contiene solo el cuadro de límite del texto resaltado y no contiene ningún texto representado.

En el ejemplo siguiente se muestra una manera de crear efectos visuales modificando el trazo y resaltado del texto convertido.

Texto con pincel de imagen aplicado al trazo Ejemplo de pincel de imagen aplicado al trazo y resaltado

Se aplica a

BuildHighlightGeometry(Point, Int32, Int32)

Devuelve un objeto Geometry que representa el rectángulo de selección del resaltado de la subcadena especificada del texto con formato.

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

Origen de la región de resaltado.

startIndex
Int32

Índice del carácter inicial para el que se van a obtener los límites de resaltado.

count
Int32

Número de caracteres que deben contener los límites de resaltado.

Devoluciones

Geometry

Objeto Geometry que representa el rectángulo de selección del resaltado de la subcadena del texto con formato.

Comentarios

El objeto devuelto Geometry contiene solo el cuadro de límite del texto resaltado y no contiene ningún texto representado.

Se aplica a