Thanks for the reply James.
I've actually already had both of those things set, hence my confusion. My custom style is essentially a ValueBreak style that compares the current map scale to the assigned value of the break, instead of a column value. So, the setup of the class goes something like this.
ShapeFileFeatureLayer CanHwyLayer = new ShapeFileFeatureLayer(this.MapPath("") + @"\App_Data\canhwy.shp");
CanHwyLayer.Name = "CanHwy";
ScaledStyleBreak s3 = new ScaledStyleBreak(4500000, LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 201, 176, 57), 1, GeoColor.FromArgb(255, 193, 167, 108), 3, false));
s3.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("NAME", "Arial", 8, DrawingFontStyles.Regular, GeoColor.SimpleColors.Black);
ScaledStyle ScaledStyle = new ScaledStyle(new Collection<ScaledStyleBreak>() { s3 }); CanHwyLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(ScaledStyle);
CanHwyLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
So here you can see that the TextColumn field is set. Also, when the ScaledStyle is created, the TextColumn is added to the RequiredFields, which propagates to the Features. When DrawCore is called, I loop through the features of the layer, all of which have the "NAME" key/value pair, and try to call the method in question on the feature and the canvas provided as a parameter to the DrawCore method. Apologies for the formatting, it wasn't really cooperating.
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
{
ScaledStyleBreak CurrentScaledStyleBreak = new ScaledStyleBreak();
double CurrentScale = ExtentHelper.GetScale(canvas.CurrentWorldExtent, canvas.Width, GeographyUnit.DecimalDegree);
for (int i = 0; i < ScaledStyleBreaks.Count; i++)
{
if ((i + 1 >= ScaledStyleBreaks.Count && CurrentScale >= ScaledStyleBreaks.OrderBy(s => s.MinimumScale).ElementAt(i).MinimumScale) || (i + 1 < ScaledStyleBreaks.Count && CurrentScale < ScaledStyleBreaks.OrderBy(s => s.MinimumScale).ElementAt(i + 1).MinimumScale && CurrentScale >= ScaledStyleBreaks.OrderBy(s => s.MinimumScale).ElementAt(i).MinimumScale))
{
CurrentScaledStyleBreak = ScaledStyleBreaks.OrderBy(s => s.MinimumScale).ElementAt(i);
break;
}
}
if (CurrentScaledStyleBreak != null)
{
foreach (Feature feature in features)
{
if (CurrentScaledStyleBreak.DefaultTextStyle != null)
{
//Error happens here
Collection<LabelingCandidate> LabelingCandidates = GetLabelingCandidates(feature, canvas);
foreach (LabelingCandidate LabelingCandidate in LabelingCandidates)
{
//do stuff here
}
}
}
}