Partage via


FormattedText.BuildHighlightGeometry Méthode

Définition

Renvoie un objet Geometry qui représente le cadre englobant de surbrillance du texte mis en forme.

Surcharges

BuildHighlightGeometry(Point)

Renvoie un objet Geometry qui représente le cadre englobant de surbrillance du texte mis en forme.

BuildHighlightGeometry(Point, Int32, Int32)

Renvoie un objet Geometry qui représente le cadre englobant de surbrillance pour une sous-chaîne spécifiée du texte mis en forme.

BuildHighlightGeometry(Point)

Renvoie un objet Geometry qui représente le cadre englobant de surbrillance du texte mis en forme.

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

Paramètres

origin
Point

L'origine de la région de surbrillance.

Retours

Geometry

L'objet Geometry qui représente le cadre englobant de surbrillance du texte mis en forme.

Exemples

L’exemple suivant montre comment créer un FormattedText objet et récupérer les géométries du texte mis en forme et sa zone englobante.

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

Remarques

La zone englobante contient l’ensemble de la zone de texte mise en forme commençant au point spécifié par origin. L’objet retourné Geometry contient uniquement la zone englobante du texte mis en surbrillance et ne contient aucun texte rendu.

L’exemple suivant illustre une façon de créer des effets visuels en modifiant le trait et en mettant en surbrillance du texte converti.

Texte avec pinceau d’image appliqué au trait Exemple de pinceau d’image appliqué au trait et à la mise en surbrillance

S’applique à

BuildHighlightGeometry(Point, Int32, Int32)

Renvoie un objet Geometry qui représente le cadre englobant de surbrillance pour une sous-chaîne spécifiée du texte mis en forme.

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

Paramètres

origin
Point

L'origine de la région de surbrillance.

startIndex
Int32

L'index du caractère initial pour lequel les limites de surbrillance devraient être obtenues.

count
Int32

Le nombre de caractères que les limites de surbrillance devraient contenir.

Retours

Geometry

L'objet Geometry qui représente le cadre englobant de surbrillance de la sous-chaîne du texte mis en forme.

Remarques

L’objet retourné Geometry contient uniquement la zone englobante du texte mis en surbrillance et ne contient aucun texte rendu.

S’applique à