Jim,
I am sorry for the delay for your questions.
Hope my following sample code can show you what is going on the labeling stuff. Of course, you can change the logic to anything you want.
public class MyTextStyle
: TextStyle
{
public MyTextStyle()
: base()
{ }
public MyTextStyle(string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush)
: base(textColumnName, textFont, textSolidBrush)
{
}
public Collection<Feature> GetLabeledFeatures(Collection<Feature> allFeatures, GeoCanvas drawingCanvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
{
Collection<Feature> unfilteredFeatures = base.FilterFeatures(allFeatures, drawingCanvas);
Collection<Feature> returnFeatures = new Collection<Feature>();
RectangleShape canvasScreenExtent = null;
if (SuppressPartialLabels)
{
canvasScreenExtent = ConvertToScreenShape(new Feature(drawingCanvas.CurrentWorldExtent), drawingCanvas).GetBoundingBox();
}
foreach (Feature feature in unfilteredFeatures)
{
Collection<LabelingCandidate> labelingCandidates = GetLabelingCandidates(feature, drawingCanvas);
foreach (LabelingCandidate labelingCandidate in labelingCandidates)
{
if (CheckDuplicate(labelingCandidate, drawingCanvas, labelsInThisLayer, labelsInAllLayers)) { continue; }
if (CheckOverlapping(labelingCandidate, drawingCanvas, labelsInThisLayer, labelsInAllLayers)) { continue; }
SimpleCandidate simpleCandidate = new SimpleCandidate(labelingCandidate.OriginalText, labelingCandidate.ScreenArea);
if (labelsInAllLayers != null) { labelsInAllLayers.Add(simpleCandidate); }
if (labelsInThisLayer != null) { labelsInThisLayer.Add(simpleCandidate); }
if (SuppressPartialLabels)
{
if (!canvasScreenExtent.Contains(labelingCandidate.ScreenArea))
{
returnFeatures.Add(feature);
}
}
else
{
returnFeatures.Add(feature);
}
}
}
return returnFeatures;
}
public Collection<Feature> GetUnLabeledFeaturesForOverlayping(Collection<Feature> allFeatures, GeoCanvas drawingCanvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
{
Collection<Feature> unfilteredFeatures = base.FilterFeatures(allFeatures, drawingCanvas);
Collection<Feature> returnFeatures = new Collection<Feature>();
foreach (Feature feature in unfilteredFeatures)
{
Collection<LabelingCandidate> labelingCandidates = GetLabelingCandidates(feature, drawingCanvas);
foreach (LabelingCandidate labelingCandidate in labelingCandidates)
{
if (CheckDuplicate(labelingCandidate, drawingCanvas, labelsInThisLayer, labelsInAllLayers))
{
continue;
}
if (CheckOverlapping(labelingCandidate, drawingCanvas, labelsInThisLayer, labelsInAllLayers))
{
returnFeatures.Add(feature);
}
SimpleCandidate simpleCandidate = new SimpleCandidate(labelingCandidate.OriginalText, labelingCandidate.ScreenArea);
if (labelsInAllLayers != null) { labelsInAllLayers.Add(simpleCandidate); }
if (labelsInThisLayer != null) { labelsInThisLayer.Add(simpleCandidate); }
}
}
return returnFeatures;
}
public Collection<Feature> GetUnLabeledFeaturesForDupulicating(Collection<Feature> allFeatures, GeoCanvas drawingCanvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
{
Collection<Feature> unfilteredFeatures = base.FilterFeatures(allFeatures, drawingCanvas);
Collection<Feature> returnFeatures = new Collection<Feature>();
foreach (Feature feature in unfilteredFeatures)
{
Collection<LabelingCandidate> labelingCandidates = GetLabelingCandidates(feature, drawingCanvas);
foreach (LabelingCandidate labelingCandidate in labelingCandidates)
{
if (CheckDuplicate(labelingCandidate, drawingCanvas, labelsInThisLayer, labelsInAllLayers))
{
returnFeatures.Add(feature);
}
if (CheckOverlapping(labelingCandidate, drawingCanvas, labelsInThisLayer, labelsInAllLayers))
{
continue;
//returnFeatures.Add(feature);
}
SimpleCandidate simpleCandidate = new SimpleCandidate(labelingCandidate.OriginalText, labelingCandidate.ScreenArea);
if (labelsInAllLayers != null) { labelsInAllLayers.Add(simpleCandidate); }
if (labelsInThisLayer != null) { labelsInThisLayer.Add(simpleCandidate); }
}
}
return returnFeatures;
}
}
Any more questions just feel free to let me know.
Thanks.
Yale