FormattedText.BuildHighlightGeometry Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Geometry Zwraca obiekt reprezentujący pole ograniczenia wyróżnienia sformatowanego tekstu.
Przeciążenia
BuildHighlightGeometry(Point) |
Geometry Zwraca obiekt reprezentujący pole ograniczenia wyróżnienia sformatowanego tekstu. |
BuildHighlightGeometry(Point, Int32, Int32) |
Geometry Zwraca obiekt reprezentujący pole ograniczenia wyróżnienia dla określonego podciągu sformatowanego tekstu. |
BuildHighlightGeometry(Point)
Geometry Zwraca obiekt reprezentujący pole ograniczenia wyróżnienia sformatowanego tekstu.
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
Parametry
- origin
- Point
Źródło regionu wyróżnienia.
Zwraca
Obiekt Geometry reprezentujący pole ograniczenia wyróżnienia sformatowanego tekstu.
Przykłady
W poniższym przykładzie pokazano, jak utworzyć FormattedText obiekt i pobrać geometrie sformatowanego tekstu i jego pola ograniczenia.
/// <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
Uwagi
Obszar pola ograniczenia zawiera cały sformatowany obszar tekstowy rozpoczynający się od punktu określonego przez origin
. Zwrócony Geometry obiekt zawiera tylko pole ograniczenia wyróżnionego tekstu i nie zawiera żadnego renderowanego tekstu.
Poniższy przykład ilustruje sposób tworzenia efektów wizualnych przez modyfikowanie pociągnięcia i wyróżniania przekonwertowanego tekstu.
Przykład pędzla obrazu zastosowanego do pociągnięcia i wyróżnienia
Dotyczy
BuildHighlightGeometry(Point, Int32, Int32)
Geometry Zwraca obiekt reprezentujący pole ograniczenia wyróżnienia dla określonego podciągu sformatowanego tekstu.
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
Parametry
- origin
- Point
Źródło regionu wyróżnienia.
- startIndex
- Int32
Indeks początkowego znaku, dla który należy uzyskać granice wyróżnienia.
- count
- Int32
Liczba znaków, które powinny zawierać granice wyróżnienia.
Zwraca
Obiekt Geometry reprezentujący pole ograniczenia wyróżnienia sformatowanego podciągu tekstu.
Uwagi
Zwrócony Geometry obiekt zawiera tylko pole ograniczenia wyróżnionego tekstu i nie zawiera żadnego renderowanego tekstu.