Class TextStyle
This class is used to label features on the map.
public class TextStyle : PositionStyle
- Inheritance
-
TextStyle
- Derived
- Inherited Members
Remarks
The text style is used for labeling things on the map. There are a great number of properties that give you a lot of control over how things are labeled. At the core, you need to set the font you want to use to label, the TextBrush to define the color and look of the text, and the TextColumnName you want to use for the text to draw. Each of the additional properties can be reviewed in the help or samples.
Constructors
TextStyle()
This is a constructor for the class.
public TextStyle()
Remarks
If you use this constructor, you should set the required properties manually.
TextStyle(string, GeoFont, GeoBrush)
This is a constructor for the class.
public TextStyle(string textColumnName, GeoFont textFont, GeoBrush textBrush)
Parameters
textColumnName
stringThis parameter is the name of the column that contains the text you want to draw.
textFont
GeoFontThis parameter is the font used to draw the text.
textBrush
GeoBrushThis parameter is the TextBrush used to draw the text.
Remarks
This constructor allows you to pass in the minimum required fields for labeling. You may want to explore the other properties to control how your labels look.
Properties
Alignment
Controls the horizontal alignment of multi-line text content. This property has no effect on single-line text.
public DrawingTextAlignment Alignment { get; set; }
Property Value
BasePoint
public PointStyle BasePoint { get; set; }
Property Value
CustomTextStyles
This property returns a collection of area styles allowing you to stack multiple area styles on top of each other.
public Collection<TextStyle> CustomTextStyles { get; }
Property Value
- Collection<TextStyle>
This property returns a collection of area styles.
Remarks
Using this collection, you can stack multiple area styles on top of each other. When we draw the features, we will draw them in order that they exist in the collection. You can use these stacks to create drop shadow effects, multiple colored outlines, etc.
DateFormat
This property gets and sets the format that will be applied to the text which can be parsed to DateTime type.
public string DateFormat { get; set; }
Property Value
- string
This property gets the format that will be applied to the text which can be parsed to DateTime type..
Remarks
With this property, you can apply formats to the text that is retrieved from the feature.
DrawingLevel
Gets or sets the DrawingLevel for this style.
public DrawingLevel DrawingLevel { get; set; }
Property Value
FittingLineInScreen
This property gets and sets whether the labeler will try to fit the label as best as it can on the visible part of a line on the screen.
public bool FittingLineInScreen { get; set; }
Property Value
- bool
This property gets whether the labeler will try to fit the label as best as it can on the visible part of a line on the screen.
Remarks
A label will normally be displayed in the center of a line. If only a small piece of the line is visible on the screen, we cannot see it's label by default. If we set this property to ture though, the label will be displayed in the center of that piece in screen.
FittingPolygonInScreen
This property gets and sets whether the labeler will try to fit the label as best as it can on the visible part of a polygon on the screen.
public bool FittingPolygonInScreen { get; set; }
Property Value
- bool
This property gets whether the labeler will try to fit the label as best as it can on the visible part of a polygon on the screen.
Remarks
A label will normally be displayed in the center of a polygon. If only a small piece of the polygon is visible on the screen, we cannot see it's label by default. If we set this property to ture though, the label will be displayed in the center of that piece in screen.
Font
This property gets and sets the font that will be used to draw the text.
public GeoFont Font { get; set; }
Property Value
- GeoFont
This property gets the font that will be used to draw the text.
Remarks
None
ForceHorizontalLabelForLine
This property gets and sets whether we should force horizontal labeling for lines.
public bool ForceHorizontalLabelForLine { get; set; }
Property Value
- bool
This property gets whether we should force horizontal labeling for lines.
Remarks
Normally, lines are labeled in the direction of the line. There may be some cases, however, when you want to have the line labeled horizontally regardless of the line's direction. In such a case, you can set this property to force the lines to be labeled horizontally.
HaloPen
This property gets and sets the halo pen you may use to draw a halo around the text.
public GeoPen HaloPen { get; set; }
Property Value
- GeoPen
This property gets the halo pen you may use to draw a halo around the text.
Remarks
The halo pen allows you to draw a halo effect around the text, making it stand out more on a busy background.
LabelPositions
Gets a value represents a keyValuePair which is a feature id and label position of the feature
public Dictionary<string, WorldLabelingCandidate> LabelPositions { get; }
Property Value
LetterCase
public DrawingTextLetterCase LetterCase { get; set; }
Property Value
Mask
This property gets and sets the AreaStyle used to draw a mask behind the text.
public AreaStyle Mask { get; set; }
Property Value
- AreaStyle
This property gets the AreaStyle used to draw a mask behind the text.
Remarks
A mask is a plate behind the text that is rectangular and slightly larger than the width and height of the text. It allows the label to stand out well on a busy background. You can also try the HaloPen property instead of the mask, if the mask effect is too pronounced.
MaskMargin
This property gets and sets the margin around the text that will be used for the mask.
public DrawingMargin MaskMargin { get; set; }
Property Value
- DrawingMargin
This property gets the margin around the text that will be used for the mask.
Remarks
This determines how much larger the mask is than the text, in pixels.
MaxCharAngleDelta
public double MaxCharAngleDelta { get; set; }
Property Value
MinDistance
public double MinDistance { get; set; }
Property Value
NumericFormat
This property gets and sets the format that will be applied to the text which can be parsed to double type.
public string NumericFormat { get; set; }
Property Value
- string
This property gets the format that will be applied to the text which can be parsed to double type..
Remarks
With this property, you can apply formats to the text that is retrieved from the feature.
RotationAngle
This property gets and sets the rotation angle of the item being positioned.
public double RotationAngle { get; set; }
Property Value
- double
This property gets the rotation angle of the item being positioned.
Remarks
None
Spacing
public double Spacing { get; set; }
Property Value
SplineType
Gets or sets the SplineType for labeling.
public SplineType SplineType { get; set; }
Property Value
TextBrush
This property gets and sets the SolidBrush that will be used to draw the text.
public GeoBrush TextBrush { get; set; }
Property Value
- GeoBrush
This property gets the SolidBrush that will be used to draw the text.
Remarks
You can use this property to draw a solid color; however, if you need to use other brushes, you can access them through the Advanced property of this class.
TextColumnName
This property gets and sets the column name in the data that you want to get the text from.
public string TextColumnName { get; set; }
Property Value
- string
This property gets the column name in the data that you want to get the text from.
Remarks
This property is used when retrieving text from a feature. You will want to specify the name of the column that contains the text you want to draw.
TextFormat
This property gets and sets the format that will be applied to the text.
public string TextFormat { get; set; }
Property Value
- string
This property gets the format that will be applied to the text.
Remarks
With this property, you can apply formats to the text that is retrieved from the feature.
WrapWidth
public double WrapWidth { get; set; }
Property Value
XOffsetInPixel
This property gets and sets the X pixel offset for drawing each feature.
public float XOffsetInPixel { get; set; }
Property Value
- float
This property gets the X pixel offset for drawing each feature.
Remarks
This property allows you to specify an X offset. When combined with a Y offset, it is useful to allow you to achieve effects such as drop shadows, etc. There also may be times when you need to modify the location of feature data so as to better align it with raster satellite data.
YOffsetInPixel
This property gets and sets the Y pixel offset for drawing each feature.
public float YOffsetInPixel { get; set; }
Property Value
- float
This property gets the Y pixel offset for drawing each feature.
Remarks
This property allows you to specify a Y offset. When combined with an X offset, it is useful to allow you to achieve effects such as drop shadows, etc. There also may be times when you need to modify the location of feature data so as to better align it with raster satellite data.
Methods
CreateMaskTextStyle(string, string, float, DrawingFontStyles, GeoColor, GeoColor)
Get simple TextStyle.
public static TextStyle CreateMaskTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor maskFillColor)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
maskFillColor
GeoColorThe GeoColor used to set the mask fill color.
Returns
- TextStyle
The desired TextStyle.
CreateMaskTextStyle(string, string, float, DrawingFontStyles, GeoColor, GeoColor, float)
Get simple TextStyle.
public static TextStyle CreateMaskTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor maskPenColor, float maskPenSize)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
maskPenColor
GeoColorThe GeoColor used to set the mask pen color.
maskPenSize
floatThe float value used to set the mask pen size.
Returns
- TextStyle
The desired TextStyle.
CreateMaskTextStyle(string, string, float, DrawingFontStyles, GeoColor, GeoColor, float, float)
Get simple TextStyle.
public static TextStyle CreateMaskTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor maskFillColor, float xOffset, float yOffset)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
maskFillColor
GeoColorThe GeoColor used to set the mask fill color.
xOffset
floatThe float value stands for the xOffset of the font on the map in pixel
yOffset
floatThe float value stands for the yOffset of the font on the map in pixel
Returns
- TextStyle
The desired TextStyle.
CreateMaskTextStyle(string, string, float, DrawingFontStyles, GeoColor, GeoColor, float, float, float)
Get simple TextStyle.
public static TextStyle CreateMaskTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor maskPenColor, float maskPenSize, float xOffset, float yOffset)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
maskPenColor
GeoColorThe GeoColor used to set the mask pen color.
maskPenSize
floatThe float value used to set the mask pen size.
xOffset
floatThe float value stands for the xOffset of the font on the map in pixel
yOffset
floatThe float value stands for the yOffset of the font on the map in pixel
Returns
- TextStyle
The desired TextStyle.
CreateMaskTextStyle(string, GeoFont, GeoBrush, AreaStyle, float, float)
Get simple TextStyle.
public static TextStyle CreateMaskTextStyle(string textColumnName, GeoFont textFont, GeoBrush textBrush, AreaStyle areaStyle, float xOffset, float yOffset)
Parameters
textColumnName
stringThe string stands for the column name.
textFont
GeoFontThe GeoFont used to set the font of the text.
textBrush
GeoBrushThe GeoSolidBrush used to set the brush of the text.
areaStyle
AreaStyleThe areaStyle used as mask of of the TextStyle.
xOffset
floatThe float value stands for the xOffset of the font on the map in pixel
yOffset
floatThe float value stands for the yOffset of the font on the map in pixel
Returns
- TextStyle
The desired TextStyle.
CreateSimpleTextStyle(string, string, float, DrawingFontStyles, GeoColor)
Get simple TextStyle.
public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
Returns
- TextStyle
The desired TextStyle.
CreateSimpleTextStyle(string, string, float, DrawingFontStyles, GeoColor, float, float)
Get simple TextStyle.
public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, float xOffset, float yOffset)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
xOffset
floatThe float value stands for the xOffset of the font on the map in pixel
yOffset
floatThe float value stands for the yOffset of the font on the map in pixel
Returns
- TextStyle
The desired TextStyle.
CreateSimpleTextStyle(string, string, float, DrawingFontStyles, GeoColor, GeoColor, float)
Get simple TextStyle.
public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor haloPenColor, float haloPenWidth)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
haloPenColor
GeoColorThe GeoColor used to set the halopen color.
haloPenWidth
floatThe float value to set the halopen width value.
Returns
- TextStyle
The desired TextStyle.
CreateSimpleTextStyle(string, string, float, DrawingFontStyles, GeoColor, GeoColor, float, float, float)
Get simple TextStyle.
public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor haloPenColor, float haloPenWidth, float xOffset, float yOffset)
Parameters
textColumnName
stringThe string stands for the column name.
fontFamilyName
stringThe string stands for the font family name. For example : "Arial".
fontSize
floatThe float number stands for the font size.
drawingFontStyle
DrawingFontStylesThe DrawingFontStyles used to set the style of the font.
fontColor
GeoColorThe GeoColor used to set the font color.
haloPenColor
GeoColorThe GeoColor used to set the halopen color.
haloPenWidth
floatThe float value to set the halopen width value.
xOffset
floatThe float value stands for the xOffset of the font on the map in pixel
yOffset
floatThe float value stands for the yOffset of the font on the map in pixel
Returns
- TextStyle
The desired TextStyle.
DrawSampleCore(GeoCanvas, DrawingRectangleF)
This method draws a sample feature on the view you provided.
protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)
Parameters
canvas
GeoCanvasThis parameter represents the view you want to draw the features on.
drawingExtent
DrawingRectangleF
Remarks
This virtual method is called from the concrete public method Draw. In this
method, we draw a sample style on the view you provided. This is typically used to
display a legend or other sample area.
When implementing this virtual method, consider the view size and draw the sample
image appropriately. You should keep in mind that the sample typically shows up on a
legend.
Exceptions
- ArgumentNullException
If you pass a null as the view, we will throw an ArgumentNullException.
- InvalidOperationException
In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.
Parse(string)
public static TextStyle Parse(string styleJson)
Parameters
styleJson
string