Condividi tramite


FormattedText.BuildHighlightGeometry Metodo

Definizione

Restituisce un oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione del testo formattato.

Overload

BuildHighlightGeometry(Point)

Restituisce un oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione del testo formattato.

BuildHighlightGeometry(Point, Int32, Int32)

Restituisce un oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione per una sottostringa specificata del testo formattato.

BuildHighlightGeometry(Point)

Restituisce un oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione del testo formattato.

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

Parametri

origin
Point

Origine dell'area di evidenziazione.

Restituisce

Geometry

Oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione del testo formattato.

Esempio

Nell'esempio seguente viene illustrato come creare un FormattedText oggetto e recuperare le geometrie del testo formattato e del relativo rettangolo di selezione.

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

Commenti

L'area del riquadro delimitatore contiene l'intera area di testo formattata a partire dal punto specificato da origin. L'oggetto restituito Geometry contiene solo il rettangolo di selezione del testo evidenziato e non contiene alcun testo di cui è stato eseguito il rendering.

Nell'esempio seguente viene illustrato un modo per creare effetti visivi modificando il tratto e l'evidenziazione del testo convertito.

Testo con pennello immagine applicato al tratto Esempio di pennello immagine applicato al tratto ed evidenziazione

Si applica a

BuildHighlightGeometry(Point, Int32, Int32)

Restituisce un oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione per una sottostringa specificata del testo formattato.

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

Parametri

origin
Point

Origine dell'area di evidenziazione.

startIndex
Int32

Indice del carattere iniziale per il quale devono essere ottenuti i limiti dell'evidenziazione.

count
Int32

Numero di caratteri che devono essere inclusi entro i limiti dell'evidenziazione.

Restituisce

Geometry

Oggetto Geometry che rappresenta il riquadro delimitatore di evidenziazione della sottostringa del testo formattato.

Commenti

L'oggetto restituito Geometry contiene solo il rettangolo di selezione del testo evidenziato e non contiene alcun testo di cui è stato eseguito il rendering.

Si applica a