FormattedText.BuildHighlightGeometry Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Devuelve un Geometry objeto que representa el cuadro de límite de resaltado del texto con formato.
Sobrecargas
| Nombre | Description |
|---|---|
| BuildHighlightGeometry(Point) |
Devuelve un Geometry objeto que representa el cuadro de límite de resaltado del texto con formato. |
| BuildHighlightGeometry(Point, Int32, Int32) |
Devuelve un Geometry objeto que representa el cuadro de límite de resaltado de una subcadena especificada del texto con formato. |
BuildHighlightGeometry(Point)
Devuelve un Geometry objeto que representa el cuadro de límite de 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
Objeto Geometry que representa el cuadro de límite de 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) 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
Comentarios
La región del rectángulo delimitador contiene el área de texto con formato completo a partir del 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.
Ejemplo de pincel de imagen aplicado al trazo y resaltado
Se aplica a
BuildHighlightGeometry(Point, Int32, Int32)
Devuelve un Geometry objeto que representa el cuadro de límite de resaltado de una 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 deben obtener los límites de resaltado.
- count
- Int32
Número de caracteres que deben contener los límites de resaltado.
Devoluciones
Objeto Geometry que representa el cuadro de límite de resaltado de la subcadena de 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.