FormattedText.BuildHighlightGeometry Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un Geometry oggetto che rappresenta il riquadro di evidenziazione del testo formattato.
Overload
| Nome | Descrizione |
|---|---|
| BuildHighlightGeometry(Point) |
Restituisce un Geometry oggetto che rappresenta il riquadro di evidenziazione del testo formattato. |
| BuildHighlightGeometry(Point, Int32, Int32) |
Restituisce un Geometry oggetto che rappresenta il rettangolo delimitatore di evidenziazione per una sottostringa specificata del testo formattato. |
BuildHighlightGeometry(Point)
Restituisce un Geometry oggetto che rappresenta il riquadro 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.
Valori restituiti
Oggetto Geometry che rappresenta il riquadro 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) 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
Commenti
L'area del riquadro delimitatore contiene l'intera area di testo formattata a partire dal punto specificato da origin. L'oggetto restituito contiene solo il rettangolo Geometry di selezione del testo evidenziato e non contiene testo sottoposto a rendering.
Nell'esempio seguente viene illustrato un modo per creare effetti visivi modificando il tratto e l'evidenziazione del testo convertito.
Esempio di pennello immagine applicato al tratto ed evidenziazione
Si applica a
BuildHighlightGeometry(Point, Int32, Int32)
Restituisce un Geometry oggetto che rappresenta il rettangolo 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 cui devono essere ottenuti i limiti di evidenziazione.
- count
- Int32
Numero di caratteri che i limiti di evidenziazione devono contenere.
Valori restituiti
Oggetto Geometry che rappresenta il riquadro di evidenziazione della sottostringa di testo formattato.
Commenti
L'oggetto restituito contiene solo il rettangolo Geometry di selezione del testo evidenziato e non contiene testo sottoposto a rendering.