Class IconStyle
This class displays an icon with text from the data of the feature.
public class IconStyle : TextStyle
- Inheritance
-
IconStyle
- Inherited Members
Remarks
You can use the IconStyle when you have an icon you want to display on the map with characters inside of that icon. For example, if you have a circular icon and you want to label the number 1-100 inside of the icon, you can use this class. You need to specify the column name where the numbers or letters will come from, as well as a font. Through various properties, you can also control the positioning of the icon, just as you would with the TextStyle.
Constructors
IconStyle()
This is the constructor for the class.
public IconStyle()
Remarks
If you use this, then you should set the properties manually -- such as the column name, font, solid brush and the image.
IconStyle(string, string, GeoFont, GeoBrush)
This is the constructor for the class.
public IconStyle(string iconPathFilename, string textColumnName, GeoFont textFont, GeoBrush textBrush)
Parameters
iconPathFilename
stringThis parameter is the path and filename of the icon you want to use.
textColumnName
stringThis parameter is the column name from which to get the data for the text.
textFont
GeoFontThis parameter is the font used to draw the text on the icon.
textBrush
GeoBrushThis parameter is the solid brush that is used to draw the text on the icon.
Remarks
This constructor allows you to pass in the path to the icon, along with the column name, font and solid brush to use. This is the most commonly used constructor. If you need to use an image from a stream, then you should use the constructor that takes a NativeImage.
IconStyle(GeoImage, string, GeoFont, GeoBrush)
This is the constructor for the class.
public IconStyle(GeoImage iconImage, string textColumnName, GeoFont textFont, GeoBrush textBrush)
Parameters
iconImage
GeoImageThis parameter is the image to use in this style.
textColumnName
stringThis parameter is the column name from which to get the data for the text.
textFont
GeoFontThis parameter is the font used to draw the text on the icon.
textBrush
GeoBrushThis parameter is the solid brush that is used to draw the text on the icon.
Remarks
This constructor allows you to use a NativeImage instead of specifying a path and filename of the icon. This is commonly used if the image comes from a stream.
Properties
IconImage
This property gets and sets the NativeImage you want to use for the image.
public GeoImage IconImage { get; set; }
Property Value
- GeoImage
This property gets the NativeImage you want to use for the image.
Remarks
You will typically want to use this property if your image is derived from a stream. Otherwise, you can use the IconFilePathName property to specify where the icon is located and we will handle the rest.
IconImageScale
This property gets and sets the scale of the image you want to draw.
public double IconImageScale { get; set; }
Property Value
- double
This property gets the scale of the image you want to draw.
Remarks
This property allows you to scale the image up and down depending on how large or small you want it. It can be changed dynamically, so you could change it at every scale level to resize the bitmap based on the current scale. A scale of 1 would be the original size, while a scale of 2 would double the size. A scale of .5 would reduce the size of the image by half, and so on.
IconPathFilename
This property gets and sets the filename and path for the image you want to use in the style.
public string IconPathFilename { get; set; }
Property Value
- string
This property gets the filename and path for the image you want to use in the style.
Remarks
You can also optionally use the IconImage property if the image you want to use is derived from a stream.
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
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.
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.
DrawSampleCore(GeoCanvas, DrawingRectangleF)
protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)
Parameters
canvas
GeoCanvasdrawingExtent
DrawingRectangleF
GetLabelingCandidateCore(Feature, GeoCanvas, GeoFont, float, float, double)
This method determines which labels will be candidates for drawing.
protected override Collection<LabelingCandidate> GetLabelingCandidateCore(Feature feature, GeoCanvas canvas, GeoFont font, float xOffsetInPixel, float yOffsetInPixel, double rotationAngle)
Parameters
feature
FeatureThis parameter represents the features you want to draw on the view.
canvas
GeoCanvasThis parameter represents the view you want to draw the features on.
font
GeoFontxOffsetInPixel
floatyOffsetInPixel
floatrotationAngle
double
Returns
- Collection<LabelingCandidate>
This method returns a collection of labeling candidates.
Remarks
This overridden method is called from the concrete public method GetLabelingCandidate. In this method, we determine if the feature passed in will be a candidate for drawing. If you have the grid method enabled, then we determine this by ensuring that only one label will be eligible per grid cell. In this way, we can ensure that labels always draw in the same place at the same scale.
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.