Labels Class Reference

Represents a list of labels of the map layer and their visualization options. More...

Collaboration diagram for Labels:
Collaboration graph

Public Member Functions

LabelCategory AddCategory (string Name)
 Adds a visualization category for labels. More...
 
void AddLabel (string Text, double x, double y, double offsetX, double offsetY, double Rotation, int Category)
 Adds a new label as the last one in the list. More...
 
void AddPart (int Index, string Text, double x, double y, double offsetX, double offsetY, double Rotation, int Category)
 Adds a part to the label with specified index. More...
 
void ApplyCategories ()
 Maps labels to the visualization categories. More...
 
void ApplyColorScheme (tkColorSchemeType Type, ColorScheme ColorScheme)
 Applies color scheme to the visualization categories. More...
 
void ApplyColorScheme2 (tkColorSchemeType Type, ColorScheme ColorScheme, tkLabelElements Element)
 Applies color scheme to the visualization categories. More...
 
void ApplyColorScheme3 (tkColorSchemeType Type, ColorScheme ColorScheme, tkLabelElements Element, int CategoryStartIndex, int CategoryEndIndex)
 Applies color scheme to the visualization categories. More...
 
void ApplyLabelExpression ()
 Generates the labels for the layer based on the label expression. More...
 
void Clear ()
 Removes all the labels and parts but not the visualization categories. More...
 
void ClearCategories ()
 Removes all the visualization categories. More...
 
void Deserialize (string newVal)
 Restores the state of the Labels class from the string. More...
 
void ForceRecalculateExpression ()
 For labels attached to shapefile layer updates the text of each label based on Expression property. More...
 
int Generate (string Expression, tkLabelPositioning Method, bool LargestPartOnly)
 Generates labels for each shape of the parent shapefile. More...
 
bool GenerateCategories (int FieldIndex, tkClassificationType ClassificationType, int numClasses)
 Generates visualization categories for labels based on certain field from the attribute table of the parent shapefile. More...
 
LabelCategory get_Category (int Index)
 Gets the visualization category (LabelCategory) with the specified index. More...
 
string get_ErrorMsg (int ErrorCode)
 Gets the description of the specific error code. More...
 
Label get_Label (int Index, int Part)
 Gets label with the specified index. More...
 
int get_NumParts (int Index)
 Gets the number of parts for the label with specified index. More...
 
LabelCategory InsertCategory (int Index, string Name)
 Inserts a new visualization category at the given position of the list. More...
 
bool InsertLabel (int Index, string Text, double x, double y, double offsetX, double offsetY, double Rotation, int Category)
 Inserts a new label at the given position. More...
 
bool InsertPart (int Index, int Part, string Text, double x, double y, double offsetX, double offsetY, double Rotation, int Category)
 Inserts a new part for the specified label. More...
 
bool LoadFromDbf (bool loadText, bool loadCategory)
 Loads text and position of labels from the attribute table of the parent shapefile. More...
 
bool LoadFromDbf2 (string xField, string yField, string angleField, string textField, string categoryField, bool loadText, bool loadCategory)
 Loads text and position of labels from the attribute table of the parent shapefile. More...
 
bool LoadFromXML (string Filename)
 Restores the state of the labels from the specified XML file. More...
 
bool MoveCategoryDown (int Index)
 Moves a specified label category down in the list. More...
 
bool MoveCategoryUp (int Index)
 Moves a specified label category up in the list. More...
 
bool RemoveCategory (int Index)
 Removes a visualization category with specified index. More...
 
bool RemoveLabel (int Index)
 Removes a label with the specified index. If the label is multipart then all its parts will be removed. More...
 
bool RemovePart (int Index, int Part)
 Removes a part of label with the specified index. More...
 
bool SaveToDbf (bool saveText, bool saveCategory)
 Saves position and text of the labels to the attribute table (dbf file). More...
 
bool SaveToDbf2 (string xField, string yField, string angleField, string textField, string categoryField, bool saveText, bool saveCategory)
 Saves positions and text of the labels to the attribute table (dbf file). More...
 
bool SaveToXML (string Filename)
 Saves the text, positions and visualization options of the labels to the XML file. More...
 
bool Select (Extents BoundingBox, int Tolerance, SelectMode SelectMode, ref object LabelIndices, ref object PartIndices)
 Returns the indices of all labels which are displayed in the given part of the map. More...
 
string Serialize ()
 Saves the state of the labels. More...
 
void set_Category (int Index, LabelCategory pVal)
 Sets the visualization category at the given position in the list. More...
 
void UpdateSizeField ()
 Marks that values of size field have changed and the size of labels should be recalculated on the next redraw. More...
 

Properties

tkLabelAlignment Alignment [get, set]
 Sets horizontal and vertical alignment of labels. More...
 
bool AutoOffset [get, set]
 Turns on or off the auto offset behaviour. More...
 
bool AvoidCollisions [get, set]
 Gets or sets the value which indicates whether a routine for preventing of label overlaps will be used. More...
 
double BasicScale [get, set]
 Map scale for which the size of labels will be equal to value set in Labels.FontSize property. More...
 
int ClassificationField [get, set]
 Gets a classification field used by unique values classification. More...
 
int CollisionBuffer [get, set]
 Gets or sets the value which affects the collision avoidance routine. Two labels are considered overlapping when the distance between their bounding rectangles is less then this value. More...
 
int Count [get]
 Gets the number of labels. More...
 
bool DynamicVisibility [get, set]
 Gets or sets the value which turns the dynamic visibility on or off. More...
 
string Expression [get, set]
 Gets or sets the expression used to generate text of labels from the attribute table of the shapefile. More...
 
string FloatNumberFormat [get, set]
 Gets or sets the formatting to be used for floating point numbers during generation of labels. More...
 
bool FontBold [get, set]
 Gets or sets the value which indicates whether the font of labels is bold. More...
 
uint FontColor [get, set]
 Gets or sets the color of the label font. More...
 
uint FontColor2 [get, set]
 Gets or sets the second color of the label font. It is used to set color gradient for the font. More...
 
tkLinearGradientMode FontGradientMode [get, set]
 Gets or sets the gradient mode for the labels. More...
 
bool FontItalic [get, set]
 Gets or sets the value which indicates whether the font of labels is italic. More...
 
string FontName [get, set]
 Gets or sets the name of the font to draw labels with, e.g. Arial. More...
 
uint FontOutlineColor [get, set]
 Sets the color of the font outline. More...
 
bool FontOutlineVisible [get, set]
 Gets or sets the value which indicates whether font outline is visible. The default value is false. More...
 
int FontOutlineWidth [get, set]
 Gets or sets the width of the font outline. The default value is 1. More...
 
int FontSize [get, set]
 Gets or sets the size of the font to draw labels with. More...
 
int FontSize2 [get, set]
 Gets or sets the maximum font size for labels (when size field is used). More...
 
bool FontStrikeOut [get, set]
 Gets or sets the value which indicates whether the font of labels is struck out. More...
 
int FontTransparency [get, set]
 Gets or sets the transparency of the font. A values between 0 (transparent) to 255 (opaque) can be used. More...
 
bool FontUnderline [get, set]
 Gets or sets the value which indicates whether the font of labels is struck out. More...
 
uint FrameBackColor [get, set]
 Gets or sets the color of the frame's background. More...
 
uint FrameBackColor2 [get, set]
 Gets or sets the second color of the frame's background. More...
 
tkLinearGradientMode FrameGradientMode [get, set]
 Gets or sets the type of gradient for the frame of the label. More...
 
uint FrameOutlineColor [get, set]
 Gets or sets the outline color of the label's frame More...
 
tkDashStyle FrameOutlineStyle [get, set]
 Gets or sets the outline style of the label's frame. More...
 
int FrameOutlineWidth [get, set]
 Gets or sets the width of the outline of the label's frame. More...
 
int FramePaddingX [get, set]
 Gets or sets the horizontal distance between the text of the label and its frame. More...
 
int FramePaddingY [get, set]
 Gets or sets the vertical distance between the text of the label and its frame. More...
 
int FrameTransparency [get, set]
 Gets or sets the transparency of the label's frame. A values between 0 (transparent) to 255 (opaque) can be used. More...
 
tkLabelFrameType FrameType [get, set]
 Gets or sets the shape of the label's frame. More...
 
bool FrameVisible [get, set]
 Gets or sets the values which indicates whether label's frame is visible. More...
 
ICallback GlobalCallback [get, set]
 Gets or sets the global callback object which is used for passing to the client an information about progress and errors. More...
 
uint HaloColor [get, set]
 Gets or sets the color of the halo around label's text. More...
 
int HaloSize [get, set]
 Gets or sets the size of the halo drawn around label's text. More...
 
bool HaloVisible [get, set]
 Gets or sets the value which indicates whether label's halo is visible. More...
 
tkLabelAlignment InboxAlignment [get, set]
 Gets or sets the value which defines an alignment of text within label's frame. More...
 
string Key [get, set]
 A text string associated with the instance of the class. Any value can be stored by developer in this property. More...
 
int LastErrorCode [get]
 Returns the code of the last error which has occurred within the instance of class. More...
 
tkLineLabelOrientation LineOrientation [get, set]
 Gets or sets the type of the label's orientation relative to the direction of the labelled shape. More...
 
bool LogScaleForSize [get, set]
 Gets or sets a value indicating whether logarithmic scale will be used to calculate the size of labels. More...
 
double MaxVisibleScale [get, set]
 Gets or sets the maximum scale at which labels are visible on the map. More...
 
int MaxVisibleZoom [get, set]
 Gets or sets the maximum zoom at which labels are visible on the map. More...
 
int MinDrawingSize [get, set]
 Gets or sets the minimum size of the shape in pixels to be labelled at the current map scale. More...
 
double MinVisibleScale [get, set]
 Get or sets the minimum scale at which labels are visible on the map. More...
 
int MinVisibleZoom [get, set]
 Gets or sets the minimum zoom at which labels are visible on the map. More...
 
int NumCategories [get]
 Number of visualization categories associated with this instance of class. More...
 
double OffsetX [get, set]
 Gets or sets the horizontal offset in pixels which is used to draw labels. More...
 
int OffsetXField [get, set]
 Gets or sets the field index to use for the horizontal offset in pixels which is used to draw labels. More...
 
double OffsetY [get, set]
 Gets or sets the vertical offset in pixels which is used to draw labels. More...
 
int OffsetYField [get, set]
 Gets or sets the field index to use for the vertical offset in pixels which is used to draw labels. More...
 
LabelCategory Options [get, set]
 Gets or sets the list of visualization options of labels. For inner use only. More...
 
tkLabelPositioning Positioning [get, set]
 Gets or sets the method of label positioning. More...
 
bool RemoveDuplicates [get, set]
 Gets or sets the value which indicates whether labels with the same text should be drawn. More...
 
tkSavingMode SavingMode [get, set]
 Gets or sets the method to save and restore the state labels. More...
 
bool ScaleLabels [get, set]
 Gets or sets the value which indicates whether the labels will change their size depending upon map scale. The default value is false. More...
 
uint ShadowColor [get, set]
 Gets or sets the color of the label's shadow. More...
 
int ShadowOffsetX [get, set]
 Gets or sets the horizontal offset of the label's shadow. More...
 
int ShadowOffsetY [get, set]
 Gets or sets the vertical offset of the label's shadow. More...
 
bool ShadowVisible [get, set]
 Gets or sets the value which indicates whether label's shadow is visible. More...
 
bool Synchronized [get, set]
 Gets or sets a boolean value which indicates whether labels should be synchronized with the parent shapefile. More...
 
tkTextRenderingHint TextRenderingHint [get, set]
 Gets or sets rendering hint to be used during GDI+ rendering. More...
 
bool UseGdiPlus [get, set]
 Gets or sets the values indicating whether GDI+ library should be used to draw labels. More...
 
bool UseVariableSize [get, set]
 Gets or sets a value indicating whether variable size for labels should be used (in the range between Labels.FontSize, Labels.FontSize2). More...
 
bool UseWidthLimits [get, set]
 Is not implemented. More...
 
tkVerticalPosition VerticalPosition [get, set]
 Gets or sets the value which affects the sequence of labels drawing relative to the map layers. More...
 
string VisibilityExpression [get, set]
 Gets or sets an expression which defines what shapes should be labelled on the map. More...
 
bool Visible [get, set]
 Gets or sets the value which indicates whether the labels will be visible on the map. More...
 

Detailed Description

Represents a list of labels of the map layer and their visualization options.

dot_inline_dotgraph_47.png

Graph description

Here is a diagram with groups of API members of Labels class.

dot_labelsgroups.png
Graph description

New API 4.8:
Added in version 4.8
Examples
ImageLabels.cs, SplitByAttribute.cs, and ToolTip.cs.

Member Function Documentation

◆ ApplyLabelExpression()

void Labels.ApplyLabelExpression ( )

Generates the labels for the layer based on the label expression.

◆ ForceRecalculateExpression()

void Labels.ForceRecalculateExpression ( )

For labels attached to shapefile layer updates the text of each label based on Expression property.

The method is necessary when the values in underlying DBF table have changed, since Labels class doesn't track these changes automatically. This method is depraceted since version 5.2 - use the new ApplyLabelExpression instead.

◆ get_ErrorMsg()

string Labels.get_ErrorMsg ( int  ErrorCode)

Gets the description of the specific error code.

Parameters
ErrorCodeThe error code returned by Labels.LastErrorCode.
Returns
The string with the description.

◆ UpdateSizeField()

void Labels.UpdateSizeField ( )

Marks that values of size field have changed and the size of labels should be recalculated on the next redraw.

New API 4.9.4:
Added in version 4.9.4

Property Documentation

◆ ClassificationField

int Labels.ClassificationField
getset

Gets a classification field used by unique values classification.

The property is used internally in couple with LabelCategory.MinValue and LabelCategory.MaxValue to avoid the parsing of expressions for the categories in case unique values classification was applied.

◆ Expression

string Labels.Expression
getset

Gets or sets the expression used to generate text of labels from the attribute table of the shapefile.

Applicable for the instances of Labels class associated with shapefile (obtained by Shapefile.Labels).

Examples
EditAttributes.cs, and RemoveShape.cs.

◆ FontSize2

int Labels.FontSize2
getset

Gets or sets the maximum font size for labels (when size field is used).

New API 4.9.4:
Added in version 4.9.4

◆ GlobalCallback

ICallback Labels.GlobalCallback
getset

Gets or sets the global callback object which is used for passing to the client an information about progress and errors.

An instance of the class which implements ICallback interface should be passed. The class should be implemented by caller.

Deprecated:
v4.9.3 Use GlobalSettings.ApplicationCallback instead.

◆ Key

string Labels.Key
getset

A text string associated with the instance of the class. Any value can be stored by developer in this property.

◆ LastErrorCode

int Labels.LastErrorCode
get

Returns the code of the last error which has occurred within the instance of class.

◆ LogScaleForSize

bool Labels.LogScaleForSize
getset

Gets or sets a value indicating whether logarithmic scale will be used to calculate the size of labels.

See also
Labels.UseVariableSize
New API 4.9.4:
Added in version 4.9.4

◆ Options

LabelCategory Labels.Options
getset

Gets or sets the list of visualization options of labels. For inner use only.

◆ UseGdiPlus

bool Labels.UseGdiPlus
getset

Gets or sets the values indicating whether GDI+ library should be used to draw labels.

The default value is true. When set to false, GDI will be used for drawing. In GDI mode no gradients and transparency is supported, while in some cases it can be somewhat faster then GDI+.

◆ UseVariableSize

bool Labels.UseVariableSize
getset

Gets or sets a value indicating whether variable size for labels should be used (in the range between Labels.FontSize, Labels.FontSize2).

New API 4.9.4:
Added in version 4.9.4