Class FormattedText
The FormattedText class is targeted at programmers needing to add some simple text to a MIL visual.
public class FormattedText
- Inheritance
-
FormattedText
- Inherited Members
Constructors
FormattedText(string, CultureInfo, FlowDirection, Typeface, double, IBrush?)
Construct a FormattedText object.
public FormattedText(string textToFormat, CultureInfo culture, FlowDirection flowDirection, Typeface typeface, double emSize, IBrush? foreground)
Parameters
textToFormat
stringString of text to be displayed.
culture
CultureInfoCulture of text.
flowDirection
FlowDirectionFlow direction of text.
typeface
TypefaceType face used to display text.
emSize
doubleFont em size in visual units (1/96 of an inch).
foreground
IBrushForeground brush used to render text.
Fields
DefaultIdealToReal
public const double DefaultIdealToReal = 0.0033333333333333335
Field Value
DefaultRealToIdeal
public const double DefaultRealToIdeal = 300
Field Value
GreatestMultiplierOfEm
public const double GreatestMultiplierOfEm = 100
Field Value
IdealInfiniteWidth
public const int IdealInfiniteWidth = 1073741822
Field Value
RealInfiniteWidth
public const double RealInfiniteWidth = 3579139.4066666667
Field Value
Properties
Baseline
The distance from the top of the first line to the baseline of the first line.
public double Baseline { get; }
Property Value
Extent
The distance from the topmost black pixel of the first line to the bottommost black pixel of the last line.
public double Extent { get; }
Property Value
FlowDirection
Defines the flow direction
public FlowDirection FlowDirection { get; set; }
Property Value
Height
The distance from the top of the first line to the bottom of the last line.
public double Height { get; }
Property Value
LineHeight
Gets or sets the height of, or the spacing between, each line where zero represents the default line height.
public double LineHeight { get; set; }
Property Value
MaxLineCount
Defines the maximum number of lines to display. The last line of text displayed is the lineCount-1'th line, or the last whole line that will fit within the count set by MaxTextHeight, whichever occurs first. Use the Trimming property to control how the omission of text is indicated
public int MaxLineCount { get; set; }
Property Value
MaxTextHeight
Sets the maximum length of a column of text. The last line of text displayed is the last whole line that will fit within this limit, or the nth line as specified by MaxLineCount, whichever occurs first. Use the Trimming property to control how the omission of text is indicated.
public double MaxTextHeight { get; set; }
Property Value
MaxTextWidth
The MaxTextWidth property defines the alignment edges for the FormattedText. For example, left aligned text is wrapped such that the leftmost glyph alignment point on each line falls exactly on the left edge of the rectangle. Note that for many fonts, especially in italic style, some glyph strokes may extend beyond the edges of the alignment rectangle. For this reason, it is recommended that clients draw text with at least 1/6 em (i.e of the font size) unused margin space either side. Zero value of MaxTextWidth is equivalent to the maximum possible paragraph width.
public double MaxTextWidth { get; set; }
Property Value
OverhangAfter
The distance from the bottom of the last line to the extent bottom.
public double OverhangAfter { get; }
Property Value
OverhangLeading
The maximum distance from the leading black pixel to the leading alignment point of a line.
public double OverhangLeading { get; }
Property Value
OverhangTrailing
The maximum distance from the trailing black pixel to the trailing alignment point of a line.
public double OverhangTrailing { get; }
Property Value
TextAlignment
Defines the alignment of text within the column
public TextAlignment TextAlignment { get; set; }
Property Value
Trimming
Defines how omission of text is indicated. CharacterEllipsis trimming allows partial words to be displayed, while WordEllipsis removes whole words to fit. Both guarantee to include an ellipsis ('...') at the end of the lines where text has been trimmed as a result of line and column limits.
public TextTrimming Trimming { get; set; }
Property Value
Width
The maximum advance width between the leading and trailing alignment points of a line, excluding the width of whitespace characters at the end of the line.
public double Width { get; }
Property Value
WidthIncludingTrailingWhitespace
The maximum advance width between the leading and trailing alignment points of a line, including the width of whitespace characters at the end of the line.
public double WidthIncludingTrailingWhitespace { get; }
Property Value
Methods
BuildGeometry(Point)
Obtains geometry for the text, including underlines and strikethroughs.
public Geometry? BuildGeometry(Point origin)
Parameters
origin
PointThe left top origin of the resulting geometry.
Returns
- Geometry
The geometry returned contains the combined geometry of all of the glyphs, underlines and strikeThroughs that represent the formatted text. Overlapping contours are merged by performing a Boolean union operation.
BuildHighlightGeometry(Point)
Builds a highlight geometry object.
public Geometry? BuildHighlightGeometry(Point origin)
Parameters
origin
PointThe origin of the highlight region
Returns
- Geometry
Geometry that surrounds the text.
BuildHighlightGeometry(Point, int, int)
Builds a highlight geometry object for a given character range.
public Geometry? BuildHighlightGeometry(Point origin, int startIndex, int count)
Parameters
origin
PointThe origin of the highlight region.
startIndex
intThe start index of initial character the bounds should be obtained for.
count
intThe number of characters the bounds should be obtained for.
Returns
- Geometry
Geometry that surrounds the specified character range.
GetMaxTextWidths()
Obtains a copy of the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The maxTextWidths array overrides the MaxTextWidth property.
public double[] GetMaxTextWidths()
Returns
- double[]
The copy of max text width array
SetCulture(CultureInfo)
Sets or changes the culture for the text object.
public void SetCulture(CultureInfo culture)
Parameters
culture
CultureInfoThe new culture for the text object.
SetCulture(CultureInfo, int, int)
Sets or changes the culture for the text object.
public void SetCulture(CultureInfo culture, int startIndex, int count)
Parameters
culture
CultureInfoThe new culture for the text object.
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontFamily(FontFamily)
Sets or changes the font family for the text object
public void SetFontFamily(FontFamily fontFamily)
Parameters
fontFamily
FontFamilyFont family
SetFontFamily(FontFamily, int, int)
Sets or changes the font family for the text object
public void SetFontFamily(FontFamily fontFamily, int startIndex, int count)
Parameters
fontFamily
FontFamilyFont family
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontFamily(string)
Sets or changes the font family for the text object
public void SetFontFamily(string fontFamily)
Parameters
fontFamily
stringFont family name
SetFontFamily(string, int, int)
Sets or changes the font family for the text object
public void SetFontFamily(string fontFamily, int startIndex, int count)
Parameters
fontFamily
stringFont family name
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontFeatures(FontFeatureCollection?)
Sets or changes the font features for the text object
public void SetFontFeatures(FontFeatureCollection? fontFeatures)
Parameters
fontFeatures
FontFeatureCollectionFeature collection
SetFontFeatures(FontFeatureCollection?, int, int)
Sets or changes the font features for the text object
public void SetFontFeatures(FontFeatureCollection? fontFeatures, int startIndex, int count)
Parameters
fontFeatures
FontFeatureCollectionFeature collection
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontSize(double)
Sets or changes the font em size measured in MIL units
public void SetFontSize(double emSize)
Parameters
emSize
doubleFont em size
SetFontSize(double, int, int)
Sets or changes the font em size measured in MIL units
public void SetFontSize(double emSize, int startIndex, int count)
Parameters
emSize
doubleFont em size
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontStyle(FontStyle)
Sets or changes the font style
public void SetFontStyle(FontStyle style)
Parameters
style
FontStyleFont style
SetFontStyle(FontStyle, int, int)
Sets or changes the font style
public void SetFontStyle(FontStyle style, int startIndex, int count)
Parameters
style
FontStyleFont style
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontTypeface(Typeface)
Sets or changes the type face
public void SetFontTypeface(Typeface typeface)
Parameters
typeface
TypefaceTypeface
SetFontTypeface(Typeface, int, int)
Sets or changes the type face
public void SetFontTypeface(Typeface typeface, int startIndex, int count)
Parameters
typeface
TypefaceTypeface
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetFontWeight(FontWeight)
Sets or changes the font weight
public void SetFontWeight(FontWeight weight)
Parameters
weight
FontWeightFont weight
SetFontWeight(FontWeight, int, int)
Sets or changes the font weight
public void SetFontWeight(FontWeight weight, int startIndex, int count)
Parameters
weight
FontWeightFont weight
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetForegroundBrush(IBrush)
Sets foreground brush used for drawing text
public void SetForegroundBrush(IBrush foregroundBrush)
Parameters
foregroundBrush
IBrushForeground brush
SetForegroundBrush(IBrush?, int, int)
Sets foreground brush used for drawing text
public void SetForegroundBrush(IBrush? foregroundBrush, int startIndex, int count)
Parameters
foregroundBrush
IBrushForeground brush
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.
SetMaxTextWidths(double[])
Sets the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The maxTextWidths array overrides the MaxTextWidth property.
public void SetMaxTextWidths(double[] maxTextWidths)
Parameters
maxTextWidths
double[]The max text width array
SetTextDecorations(TextDecorationCollection)
Sets or changes the text decorations
public void SetTextDecorations(TextDecorationCollection textDecorations)
Parameters
textDecorations
TextDecorationCollectionText decorations
SetTextDecorations(TextDecorationCollection, int, int)
Sets or changes the text decorations
public void SetTextDecorations(TextDecorationCollection textDecorations, int startIndex, int count)
Parameters
textDecorations
TextDecorationCollectionText decorations
startIndex
intThe start index of initial character to apply the change to.
count
intThe number of characters the change should be applied to.