I am using a custom point style to draw rotated and scaled point symbols based on database values. I have successfully implemented this code. I found that I couldn't use DefaultLineStyle if I have added a CustomStyle, so I am trying to implement a custom line style as well. This will work out well for my project, but I have run into an problem. The DrawCore override in the custom line style trys to draw point symbols as well. Code is as follows:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.DesktopEdition;
class MyLineStyle : LineStyle
{
private LineStyle lineStyle;
public MyLineStyle()
: this(new LineStyle())
{ }
public MyLineStyle(LineStyle lineStyle)
{
this.lineStyle = lineStyle;
}
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
{
foreach (Feature feature in features)
{
float Width = Convert.ToSingle(feature.ColumnValues["Width"]);
GeoColor Color = new GeoColor(0, 0, 0);
if (MyProject.UseLayers)
{
Color = GeoColor.FromWin32(DataInterface.GetLayerColor(Convert.ToInt32(feature.ColumnValues["Layer"])));
}
else
{
Color = GeoColor.FromWin32(Convert.ToInt32(feature.ColumnValues["Color"]));
}
canvas.DrawLine(feature, new GeoPen(Color, Width), DrawingLevel.LevelFour, 0, 0);
}
//base.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers);
}
protected override Collection<string> GetRequiredColumnNamesCore()
{
Collection<string> columns = new Collection<string>();
columns = lineStyle.GetRequiredColumnNames();
if (!columns.Contains("FeatureText"))
{
columns.Add("FeatureText");
}
if (!columns.Contains("TextJust"))
{
columns.Add("TextJust");
}
if (!columns.Contains("Angle"))
{
columns.Add("Angle");
}
if (!columns.Contains("RScale"))
{
columns.Add("RScale");
}
if (!columns.Contains("SymbolImage"))
{
columns.Add("SymbolImage");
}
if (!columns.Contains("Width"))
{
columns.Add("Width");
}
if (!columns.Contains("Color"))
{
columns.Add("Color");
}
if (!columns.Contains("Layer"))
{
columns.Add("Layer");
}
return columns;
}
}
The error occurs at canvas.DrawLine. When I check Feature.GetWellKnownText I get "POINT(582429.33 266601.63)". I could check this but it seems a waste of processing time since point features shouldn't go through LineStyle.DrawCore. What am I doing wrong? Do all features go through DrawCore for all styles? Is there an easier way to check the feature type?