Skip to content

TextStyle

Namespace: ThinkGeo.Core

This class is used to label features on the map.

public class TextStyle : PositionStyle

Inheritance ObjectStylePositionStyleTextStyle

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.

Properties

XOffsetInPixel

This property gets and sets the X pixel offset for drawing each feature.

public float XOffsetInPixel { get; set; }

Property Value

Single
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

Single
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.

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

Boolean

        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

Boolean

        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.

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.

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

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.

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.

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.

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.

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

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.

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.

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.

ForceHorizontalLabelForLine

This property gets and sets whether we should force horizontal labeling for lines.

public bool ForceHorizontalLabelForLine { get; set; }

Property Value

Boolean
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.

SplineType

Gets or sets the SplineType for labeling.

public SplineType SplineType { get; set; }

Property Value

SplineType

DrawingLevel

Gets or sets the DrawingLavel for this style.

public DrawingLevel DrawingLevel { get; set; }

Property Value

DrawingLevel

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

Dictionary<String, WorldLabelingCandidate>

Alignment

public DrawingTextAlignment Alignment { get; set; }

Property Value

DrawingTextAlignment

LetterCase

public DrawingTextLetterCase LetterCase { get; set; }

Property Value

DrawingTextLetterCase

MaxCharAngleDelta

public double MaxCharAngleDelta { get; set; }

Property Value

Double

MinDistance

public double MinDistance { get; set; }

Property Value

Double

Spacing

public double Spacing { get; set; }

Property Value

Double

WrapWidth

public double WrapWidth { get; set; }

Property Value

Double

BasePoint

public PointStyle BasePoint { get; set; }

Property Value

PointStyle

PolygonLabelingLocationMode

This property gets and sets the mode that determines how to locate polygon's labeling

public PolygonLabelingLocationMode PolygonLabelingLocationMode { get; set; }

Property Value

PolygonLabelingLocationMode

        This property gets the mode that determines how to locate polygon's labeling

Remarks:

There are two ways to handle polygon's labeling location. The first is to use polygon's centroid as the labeling location, the second way is to use polygon's boungdingbox center as the labeling location.

MaxNudgingInPixel

public int MaxNudgingInPixel { get; set; }

Property Value

Int32

NudgingIntervalInPixel

public float NudgingIntervalInPixel { get; set; }

Property Value

Single

BestPlacementSymbolWidth

public float BestPlacementSymbolWidth { get; set; }

Property Value

Single

BestPlacementSymbolHeight

public float BestPlacementSymbolHeight { get; set; }

Property Value

Single

AbbreviationDictionary

public Dictionary<string, string> AbbreviationDictionary { get; set; }

Property Value

Dictionary<String, String>

LeaderLineStyle

public LineStyle LeaderLineStyle { get; set; }

Property Value

LineStyle

LeaderLineRule

public LabelLeaderLinesRule LeaderLineRule { get; set; }

Property Value

LabelLeaderLinesRule

LeaderLineMinimumLengthInPixels

public float LeaderLineMinimumLengthInPixels { get; set; }

Property Value

Single

GridSize

This property gets and sets the grid size used for deterministic labeling.

public int GridSize { get; set; }

Property Value

Int32
This property gets the grid sized used for deterministic labeling.

Remarks:

The grid size determines how many labels will be considered as candidates for drawing. The smaller the grid size, the higher the density of candidates. Making the grid size too small may have a performance impact.

DuplicateRule

This property gets and sets the rule that determines how duplicate labels are handled.

public LabelDuplicateRule DuplicateRule { get; set; }

Property Value

LabelDuplicateRule

        This property gets the rule that determines how duplicate labels are
        handled.

Remarks:

There are three ways to handle duplicate label names. The first is to suppress all duplicates, which means if there are two street segments with the same name then only one will be drawn. The second way is to suppress duplicate labels only if they are in one quarter of the screen. In this way, the screen will be divided into four quadrants, and if the two duplicate labels are in different quadrants, then they will both draw. The last way is to draw all duplicates.

OverlappingRule

This property gets and sets the rule that determines how overlapping labels are handled.

public LabelOverlappingRule OverlappingRule { get; set; }

Property Value

LabelOverlappingRule
This property gets the rule that determines overlapping labels are handled.

Remarks:

This defines the rules for label overlapping. Currently, either we allow overlapping or we do not. In the future, we may extend this to allow some percentage of partial overlapping.

AllowLabelNudging

public bool AllowLabelNudging { get; set; }

Property Value

Boolean

AllowLineCarriage

This property gets and sets whether the labeler will allow carriage returns to be inserted.

public bool AllowLineCarriage { get; set; }

Property Value

Boolean

        This property gets whether the labeler will allow carriage returns to be
        inserted.

Remarks:

This property enables the labeler to split long labels into multiple lines if need be. For instance, if you have a lake whose name is "Southern Homestead Lake," then the labeler may try and break the name onto multiple lines in order to better label the feature.

SuppressPartialLabels

This property gets and sets whether a partial label in the current extent will be drawn or not.

public bool SuppressPartialLabels { get; set; }

Property Value

Boolean

Remarks:

This property provides a solution to the "cut off" label issue in Map Suite Web Edition and Desktop Edition, which occurs when multiple tiles exist. When you set this property to true, any labels outside of the current extent will not be drawn.

ForceLineCarriage

This property gets and sets whether the labeler will force carriage returns to be inserted.

public bool ForceLineCarriage { get; set; }

Property Value

Boolean

        This property gets whether the labeler will force carriage returns to be
        inserted.

Remarks:

This property forces the labeler to split long labels into multiple lines. For instance, if you have a lake whose name is "Southern Homestead Lake," then the labeler will break the name onto multiple lines in order to better label the feature.

FittingPolygon

This property gets and sets whether the labeler will try to fit the label as best as it can within the boundary of a polygon.

public bool FittingPolygon { get; set; }

Property Value

Boolean

        This property gets whether the labeler will try to fit the label as best as
        it can within the boundary of a polygon.

Remarks:

None

LabelAllPolygonParts

This property gets and sets whether the labeler will label every part of a multi-part polygon.

public bool LabelAllPolygonParts { get; set; }

Property Value

Boolean

        This property gets whether the labeler will label every part of a multi-part
        polygon.

Remarks:

In some cases, you may want to label all of the parts of a multi-part polygon, while in other cases you may not. For example, you may have a series of lakes where you do want to label each polygon. In another case, you may have a country with many small islands and in this case you only want to label the largest polygon.

LabelAllLineParts

This property gets and sets whether the labeler will label every part of a multi-part line.

public bool LabelAllLineParts { get; set; }

Property Value

Boolean

        This property gets whether the labeler will label every part of a multi-part
        line.

Remarks:

In some cases, you may want to label all of the parts of a multi-part line, while in other cases you may not.

FittingPolygonFactor

This property gets and sets the factor to which it will keep the label inside of the polygon.

public double FittingPolygonFactor { get; set; }

Property Value

Double

        This property gets the factor to which it will keep the label inside of the
        polygon.

Remarks:

None

TextLineSegmentRatio

This property gets and sets the ratio required for the label length to match the line length.

public double TextLineSegmentRatio { get; set; }

Property Value

Double

        This property gets the ratio required for the label length to match the line
        length.

Remarks:

This allows you to suppress labels where the label length would greatly exceed the line length. For example, if you set the ratio to 1, then the label will be suppressed if it is longer than the line. If the ratio is lower, then the label would need to be shorter than the line. If higher, then the label is allowed to run past the length of the line. This allows you to control the look of things like road labeling.

TextPlacement

This property gets and sets the location of the label for point features relative to the point.

public TextPlacement TextPlacement { get; set; }

Property Value

TextPlacement

        This property gets the location of the label for point features relative to the
        point.

Remarks:

This property allows you to choose where the labels are created relative to the point. For example, you can set the property to RightCenter, which would ensure that all labels are placed to the right of and vertically centered with the point. Different kinds of point layers can be positioned differently. If the point layer is dense and position is not a main concern, then you can try the BestPlacement property. That property overrides this property and tries to fit the label in the best location so that the minimum number of labels are suppressed due to overlapping issues.

MaskType

public MaskType MaskType { get; set; }

Property Value

MaskType

TextContent

This property gives you the option to customize the labeling by using one or more columns. For example supposing I have 2 columns "ColumnA" and "ColumnB" with the values of "ValueA" and "ValueB", by setting this property to "{ColumnA} - {ColumnB}", it will draw "ValueA - ValueB" for the corresponding feature. Do remember to add the columns you want to draw (ColumnA and ColumnB in the case above) to RequiredColumnNames collection;

public string TextContent { get; set; }

Property Value

String

MaxAdjacentCharDeltaAngle

public double MaxAdjacentCharDeltaAngle { get; set; }

Property Value

Double

Name

This property gets and set the name of the style.

public string Name { get; set; }

Property Value

String
This property gets the name of the style.

Remarks:

This name is not used by the system; it is only for the developer. However, it can be used if you generate your own legend.

IsActive

This property gets and sets the active status of the style.

public bool IsActive { get; set; }

Property Value

Boolean
This property gets the active status of the style.

Remarks:

If the style is not active then it will not draw.

RequiredColumnNames

This property gets the collection of fields that are required for the style.

public Collection<string> RequiredColumnNames { get; }

Property Value

Collection<String>

        This property gets the collection of fields that are required for the
        style.

Remarks:

This property gets the collection of fields that are required for the style. These are in addition to any other columns you specify in styles that inherit from this one. For example, if you have use a ValueStyle and it requires a column name for the value comparison, then that column does not need to be in this collection. You only use the RequiredColumnNames for columns you need beyond those required by specific inherited styles.

Filters

public Collection<string> Filters { get; }

Property Value

Collection<String>

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 String
This parameter is the name of the column that contains the text you want to draw.

textFont GeoFont
This parameter is the font used to draw the text.

textBrush GeoBrush
This 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.

Methods

Parse(String)

public static TextStyle Parse(string styleJson)

Parameters

styleJson String

Returns

TextStyle

Parse(JObject)

internal static TextStyle Parse(JObject jObject)

Parameters

jObject JObject

Returns

TextStyle

CreateSimpleTextStyle(String, String, Single, DrawingFontStyles, GeoColor)

Get simple TextStyle.

public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor)

Parameters

textColumnName String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

Returns

TextStyle
The desired TextStyle.

CreateSimpleTextStyle(String, String, Single, DrawingFontStyles, GeoColor, Single, Single)

Get simple TextStyle.

public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, float xOffset, float yOffset)

Parameters

textColumnName String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

xOffset Single
The float value stands for the xOffset of the font on the map in pixel

yOffset Single
The float value stands for the yOffset of the font on the map in pixel

Returns

TextStyle
The desired TextStyle.

CreateSimpleTextStyle(String, String, Single, DrawingFontStyles, GeoColor, GeoColor, Single)

Get simple TextStyle.

public static TextStyle CreateSimpleTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor haloPenColor, float haloPenWidth)

Parameters

textColumnName String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

haloPenColor GeoColor
The GeoColor used to set the halopen color.

haloPenWidth Single
The float value to set the halopen width value.

Returns

TextStyle
The desired TextStyle.

CreateSimpleTextStyle(String, String, Single, DrawingFontStyles, GeoColor, GeoColor, Single, Single, Single)

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 String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

haloPenColor GeoColor
The GeoColor used to set the halopen color.

haloPenWidth Single
The float value to set the halopen width value.

xOffset Single
The float value stands for the xOffset of the font on the map in pixel

yOffset Single
The float value stands for the yOffset of the font on the map in pixel

Returns

TextStyle
The desired TextStyle.

CreateMaskTextStyle(String, String, Single, DrawingFontStyles, GeoColor, GeoColor)

Get simple TextStyle.

public static TextStyle CreateMaskTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor maskFillColor)

Parameters

textColumnName String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

maskFillColor GeoColor
The GeoColor used to set the mask fill color.

Returns

TextStyle
The desired TextStyle.

CreateMaskTextStyle(String, String, Single, DrawingFontStyles, GeoColor, GeoColor, Single, Single)

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 String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

maskFillColor GeoColor
The GeoColor used to set the mask fill color.

xOffset Single
The float value stands for the xOffset of the font on the map in pixel

yOffset Single
The float value stands for the yOffset of the font on the map in pixel

Returns

TextStyle
The desired TextStyle.

CreateMaskTextStyle(String, GeoFont, GeoBrush, AreaStyle, Single, Single)

Get simple TextStyle.

public static TextStyle CreateMaskTextStyle(string textColumnName, GeoFont textFont, GeoBrush textBrush, AreaStyle areaStyle, float xOffset, float yOffset)

Parameters

textColumnName String
The string stands for the column name.

textFont GeoFont
The GeoFont used to set the font of the text.

textBrush GeoBrush
The GeoSolidBrush used to set the brush of the text.

areaStyle AreaStyle
The areaStyle used as mask of of the TextStyle.

xOffset Single
The float value stands for the xOffset of the font on the map in pixel

yOffset Single
The float value stands for the yOffset of the font on the map in pixel

Returns

TextStyle
The desired TextStyle.

CreateMaskTextStyle(String, String, Single, DrawingFontStyles, GeoColor, GeoColor, Single)

Get simple TextStyle.

public static TextStyle CreateMaskTextStyle(string textColumnName, string fontFamilyName, float fontSize, DrawingFontStyles drawingFontStyle, GeoColor fontColor, GeoColor maskPenColor, float maskPenSize)

Parameters

textColumnName String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

maskPenColor GeoColor
The GeoColor used to set the mask pen color.

maskPenSize Single
The float value used to set the mask pen size.

Returns

TextStyle
The desired TextStyle.

CreateMaskTextStyle(String, String, Single, DrawingFontStyles, GeoColor, GeoColor, Single, Single, Single)

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 String
The string stands for the column name.

fontFamilyName String
The string stands for the font family name. For example : "Arial".

fontSize Single
The float number stands for the font size.

drawingFontStyle DrawingFontStyles
The DrawingFontStyles used to set the style of the font.

fontColor GeoColor
The GeoColor used to set the font color.

maskPenColor GeoColor
The GeoColor used to set the mask pen color.

maskPenSize Single
The float value used to set the mask pen size.

xOffset Single
The float value stands for the xOffset of the font on the map in pixel

yOffset Single
The 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 void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)

Parameters

canvas GeoCanvas
This parameter represents the view you want to draw the features on.

drawingExtent DrawingRectangleF

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.

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.

Events

Formatting

public event EventHandler<FormattingPositionStyleEventArgs> Formatting;

Formatted

public event EventHandler<FormattedPositionStyleEventArgs> Formatted;