Labels generation

Functions

void Labels.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 Labels.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 Labels.Clear ()
 Removes all the labels and parts but not the visualization categories. More...
 
int Labels.Generate (string Expression, tkLabelPositioning Method, bool LargestPartOnly)
 Generates labels for each shape of the parent shapefile. More...
 
Label Labels.get_Label (int Index, int Part)
 Gets label with the specified index. More...
 
int Labels.get_NumParts (int Index)
 Gets the number of parts for the label with specified index. More...
 
bool Labels.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 Labels.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 Labels.RemoveLabel (int Index)
 Removes a label with the specified index. If the label is multipart then all its parts will be removed. More...
 
bool Labels.RemovePart (int Index, int Part)
 Removes a part of label with the specified index. More...
 

Properties

int Labels.Count [get]
 Gets the number of labels. More...
 
bool Labels.Synchronized [get, set]
 Gets or sets a boolean value which indicates whether labels should be synchronized with the parent shapefile. More...
 

Detailed Description

Here is a list of properties and methods for adding labels (or their parts) to the map or removing them. This module is a part of the documentation of Labels class.

dot_inline_dotgraph_12.png

Graph description

Function Documentation

◆ AddLabel()

void Labels.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.

All the parameters passed to the method can be changed afterwards using Labels.get_Label() property.

Parameters
TextThe text of the new label.
xThe x coordinate of the new label.
yThe y coordinate of the new label.
offsetXThe x offset in pixels of the new label.
offsetYThe y offset in pixels of the new label.
RotationThe rotation of the label in degrees. Positive values set clockwise rotation, negative - counter-clockwise.
CategoryThe index of visualization category to be used for the label drawing. Default value is -1, which means the default drawing options will be used.
New API 5.2:
offsetX & offsetY were introduced in version 5.2
Examples
ImageLabels.cs, SplitByAttribute.cs, and ToolTip.cs.

◆ AddPart()

void Labels.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.

According to the shapefile specification shapes such as polylines or polygons can have multiple parts. Use this method to add a separate label for each part of the parent shape.

Parameters
IndexThe index of label to add a part to.
TextThe text to be displayed.
xThe x coordinate of the part.
yThe y coordinate of the part.
offsetXThe x offset in pixels of the new label.
offsetYThe y offset in pixels of the new label.
RotationThe rotation of the label's part.
CategoryThe index of visualization category to be used for the label drawing. Default value is -1, which means the default drawing options will be used.

///

New API 5.2:
offsetX & offsetY were introduced in version 5.2

◆ Clear()

void Labels.Clear ( )

Removes all the labels and parts but not the visualization categories.

Examples
ToolTip.cs.

◆ Generate()

int Labels.Generate ( string  Expression,
tkLabelPositioning  Method,
bool  LargestPartOnly 
)

Generates labels for each shape of the parent shapefile.

Applicable for the instances of Labels class associated with shapefile, i.e. returned by Shapefile.Labels property.

Parameters
ExpressionThe expression to be used for generation of the text for labels.
MethodThe method to calculate position of each label.
LargestPartOnlyA value which indicates whether labels should be created for each part of the multipart shape or for the largest part only.
Returns
The number of generated labels.
Examples
EditAttributes.cs, LabelSelection.cs, MinimalDistance.cs, SelectBox.cs, SelectByQuery.cs, ToolTip.cs, TrackCars.cs, Tracking.cs, and ZoomToValues.cs.

◆ get_Label()

Label Labels.get_Label ( int  Index,
int  Part 
)

Gets label with the specified index.

Parameters
IndexThe index of label to return.
PartThe part of the label to return. In case of single part labels 0 should be used.
Returns
A reference to the label or null reference in case of incorrect index.

◆ get_NumParts()

int Labels.get_NumParts ( int  Index)

Gets the number of parts for the label with specified index.

Parameters
IndexThe index of the label.
Returns
The number of parts or -1 in case of incorrect index

◆ InsertLabel()

bool Labels.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.

Parameters
IndexThe index to insert the label at.
TextThe text of the label.
xThe x coordinate of the label.
yThe y coordinate of the label.
offsetXThe x offset in pixels of the label.
offsetYThe y offset in pixels of the label.
RotationThe angle of label rotation.
CategoryThe index of the visualization category for the label. Use -1 if the label doesn't belong to any category.
Returns
True on success and false otherwise.
New API 5.2:
offsetX & offsetY were introduced in version 5.2

◆ InsertPart()

bool Labels.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.

Labels can have several parts which correspond to the parts of shapes they belong to.

Parameters
IndexThe index of the label.
PartThe index to insert the new part at.
TextThe text of the label.
xThe x coordinate of the label.
yThe y coordinate of the label.
offsetXThe x offset in pixels of the label.
offsetYThe y offset in pixels of the label.
RotationThe rotation of the label in degrees.
CategoryThe index of visualization category. Use -1 if the label doesn't belong to any category.
Returns
True on success or false otherwise.

///

New API 5.2:
offsetX & offsetY were introduced in version 5.2

◆ RemoveLabel()

bool Labels.RemoveLabel ( int  Index)

Removes a label with the specified index. If the label is multipart then all its parts will be removed.

Parameters
IndexThe index of the label to be removed.
Returns
True on success and false otherwise.

◆ RemovePart()

bool Labels.RemovePart ( int  Index,
int  Part 
)

Removes a part of label with the specified index.

Parameters
IndexThe index of the label.
PartThe index of part to be removed.
Returns
True on success and false otherwise.

Properties

◆ Count

int Labels.Count
get

Gets the number of labels.

Each label can have more then one part.

Examples
RemoveShape.cs.

◆ Synchronized

bool Labels.Synchronized
getset

Gets or sets a boolean value which indicates whether labels should be synchronized with the parent shapefile.

Synchronization means that labels will be automatically added or removed simultaneously with the corresponding operation in the shapefile. Labels can be synchronized only if their number is equal to the number of shapes.

See also
Labels.Count, Shapefile.NumShapes