Thank you David. With your tip, I have the Scaling Symbol class exactely as I wanted. Now that I know the Draw method of Style exists and I understand how to use it, I could write the appropriate code in the Override DrawCore method. See my new class:
public class ScalingCapitalStyle : Style
{
private GeographyUnit mapUnit;
private double maximumScale;
private double minimumScale;
private double maximumSize;
private double minimumSize;
private float xOffsetInPixel;
private float yOffsetInPixel;
// A default constructor that just calls the main constructor
public ScalingCapitalStyle()
: this(GeographyUnit.DecimalDegree, double.MaxValue, 0, 20, 10)
{
}
// A constructor with fewer parameters that calls the main constructor
public ScalingCapitalStyle(GeographyUnit mapUnit, double MaximumScale, double MinimumScale, double MaximumSize, double MinimumSize)
{
this.maximumScale = MaximumScale;
this.minimumScale = MinimumScale;
this.maximumSize = MaximumSize;
this.minimumSize = MinimumSize;
this.mapUnit = mapUnit;
}
// This is the map unit to determine the scale.
public GeographyUnit MapUnit
{
get { return mapUnit; }
set { mapUnit = value; }
}
// The maximum scale will be the largest scale used to calculate the size of the image.
// If the scale gets larger than the max then we compute the scaling based on
// this number instead. This is mean that after this scale the image will not get
// any smaller no matter how much more you zoom out.
public double MaximumScale
{
get { return maximumScale; }
set { maximumScale = value; }
}
// The minimum scale will be the smallest scale used to calculate the size of the image.
// If the scale gets smaller than the min then we compute the scaling based on
// this number instead. This is mean that after this scale the image will not get
// any larger no matter how much more you zoom in.
public double MinimumScale
{
get { return minimumScale; }
set { minimumScale = value; }
}
// The MaximumSize is the size of the image at MinimumScale and lower.
public double MaximumSize
{
get { return maximumSize; }
set { maximumSize = value; }
}
// The MinimumSize is the size of the image at MaximumScale and higher.
public double MinimumSize
{
get { return minimumSize; }
set { minimumSize = value; }
}
// This is the X offset in pixels for the image.
public float XOffsetInPixel
{
get { return xOffsetInPixel; }
set { xOffsetInPixel = value; }
}
// This is the Y offset in pixels for the image.
public float YOffsetInPixel
{
get { return yOffsetInPixel; }
set { yOffsetInPixel = value; }
}
// This is the method we needed to override.
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
{
double currentScale = ExtentHelper.GetScale(canvas.CurrentWorldExtent, canvas.Width, mapUnit);
// Enforce the minimum and maximum scale properties
if (currentScale > maximumScale) { currentScale = maximumScale; }
if (currentScale < minimumScale) { currentScale = minimumScale; }
int PointSize = (int)(maximumSize - ((currentScale - minimumScale) * (maximumSize - minimumSize)) /
(maximumScale - minimumScale));
int PointSize2 = (int)(PointSize * 0.9);
int PointSize3 = (int)(PointSize * 0.6);
PointStyle pointStyle1 = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.StandardColors.Black), PointSize);
PointStyle pointStyle2 = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.StandardColors.White), PointSize2);
PointStyle pointStyle3 = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.StandardColors.Black), PointSize3);
pointStyle1.Draw(features, canvas, labelsInThisLayer, labelsInAllLayers);
pointStyle2.Draw(features, canvas, labelsInThisLayer, labelsInAllLayers);
pointStyle3.Draw(features, canvas, labelsInThisLayer, labelsInAllLayers);
}
}