Class IconValueStyle
This class allows you to choose different icons based on values in the data of a feature.
public class IconValueStyle : PositionStyle
- Inheritance
-
IconValueStyle
- Inherited Members
Remarks
When you create an IconValueStyle, you need to add multiple IconValueItems to its
collection. You input the column name in the IconValueStyle and it will compare the
data's value to each IconValueItem's FieldValue. If they match, then it will draw
the Feature using the properties of the IconValueItem. In this way, you can render
different data with different icons or text.
The MinimumLength and MaximumLength properties are important because they are used
to ensure that a properly sized icon is used to draw things like road signs. For example,
you can set the minimum and maximum values so that the sign icon for a single-digit road
number uses one icon, while a two-digit road uses another, wider sign icon
in a separate IconValueItem.
Constructors
IconValueStyle()
This is the constructor for the class.
public IconValueStyle()
Remarks
If you use this constructor, then you need to set the required properties manually.
IconValueStyle(string)
This is the constructor for the class.
public IconValueStyle(string columnName)
Parameters
columnName
stringThis parameter is the column name you want to match on.
Remarks
None
IconValueStyle(string, IEnumerable<IconValueItem>)
This is the constructor for the class.
public IconValueStyle(string columnName, IEnumerable<IconValueItem> iconValueItems)
Parameters
columnName
stringThis parameter is the column name you want to match on.
iconValueItems
IEnumerable<IconValueItem>This parameter is the icon value items you want to match on.
Remarks
None
Properties
ColumnName
This property gets and sets the column name that will be used for the drawing and matching.
public string ColumnName { get; set; }
Property Value
- string
This property gets the column name that will be used for the drawing and matching.
Remarks
This column name will be used to draw the text on the icon (if necessary) and to also match the value in the IconStyleItem.
IconValueItems
This property gets the collection of IconValueItems for matching.
public Collection<IconValueItem> IconValueItems { get; }
Property Value
- Collection<IconValueItem>
This property gets the collection of IconValueItems for matching.
Remarks
You should create your IconValueItems and place them in this collection for consideration.
Methods
DrawCore(IEnumerable<Feature>, GeoCanvas, Collection<SimpleCandidate>, Collection<SimpleCandidate>)
This method draws the features on the view you provided.
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
Parameters
features
IEnumerable<Feature>This parameter represents the features you want to draw on the view.
canvas
GeoCanvasThis parameter represents the view you want to draw the features on.
labelsInThisLayer
Collection<SimpleCandidate>The labels will be drawn in the current layer only.
labelsInAllLayers
Collection<SimpleCandidate>The labels will be drawn in all layers.
Remarks
This overridden method is called from the concrete public method Draw. In this
method, we take the features you passed in and draw them on the view you provided.
Each style (based on its properties) may draw each feature differently.
When overriding this method, consider each feature and its column data values. You can
use the full power of the GeoCanvas to do the drawing. If you need column data for a
feature, be sure to override the GetRequiredColumnNamesCore and add the columns you need
to the collection. In many of the styles, we add properties to allow the user to specify
which field they need; then, in the GetRequiredColumnNamesCore, we read that property and
add it to the collection.
Exceptions
- InvalidOperationException
In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.
- ArgumentNullException
If you pass a null as the view, we will throw an ArgumentNullException.
- ArgumentNullException
If you pass a null as the features, we will throw an ArgumentNullException.
GetLabelingCandidateCore(Feature, GeoCanvas, GeoFont, float, float, double)
This method determines whether the specified feature is a good candidate to be labeled, based on the labeling properties set.
protected override Collection<LabelingCandidate> GetLabelingCandidateCore(Feature feature, GeoCanvas canvas, GeoFont font, float xOffsetInPixel, float yOffsetInPixel, double rotationAngle)
Parameters
feature
FeatureThis parameter is the feature that will be considered as a labeling candidate.
canvas
GeoCanvasThis parameter is the view that will be used to draw the feature. This method will not draw on this view, but rather will use it to determine font size, etc.
font
GeoFontxOffsetInPixel
floatyOffsetInPixel
floatrotationAngle
double
Returns
Remarks
This overridden method is called from the concrete public method Draw. In this method, we take the feature you passed in and determine if it is a candidate for labeling. If it is, then we will add it to the return collection. The algorithm to determine whether the label will draw is complex and determined by a number of properties and factors.
GetRequiredColumnNamesCore()
This method returns the column data for each feature that is required for the style to properly draw.
protected override Collection<string> GetRequiredColumnNamesCore()
Returns
- Collection<string>
This method returns a collection of the column names that it needs.
Remarks
This abstract method is called from the concrete public method
GetRequiredFieldNames. In this method, we return the column names that are required for
the style to draw the feature properly. For example, if you have a style that colors
areas blue when a certain column value is over 100, then you need to be sure you include
that column name. This will ensure that the column data is returned to you in the
feature when it is ready to draw.
In many of the styles, we add properties to allow the user to specify which field they
need; then, in the GetRequiredColumnNamesCore, we read that property and add it to the
collection.
Exceptions
- ArgumentNullException
If columnName is null, we will throw an ArgumentNullException.