Ryan,
As you said, normally when you Feture.GetShape() it will always return Polygon, because in our internal system we ONLY use PolygonShape to deal with Ellipse/Circle/ RectangleShape/PolygonShape.
But in a trick way, we can record this information in the columnValues in this feature. We provide some sample codes which you can have identification about the shapes from which you want to make a difference. Based on this, you can have different operations.
public class CustomerEditInteractiveOverlay : EditInteractiveOverlay
{
protected override IEnumerable<Feature> CalculateVertexControlPointsCore(Feature feature)
{
Collection<Feature> returnFeatures = new Collection<Feature>();
if (!(string.Equals(feature.ColumnValues["ShapeType"], "RectangleShape") ||
string.Equals(feature.ColumnValues["ShapeType"], "EllipseShape")))
{
IEnumerable<Feature> features = base.CalculateVertexControlPointsCore(feature);
foreach (Feature originalFeature in features)
{
returnFeatures.Add(originalFeature);
}
}
return returnFeatures;
}
protected override IEnumerable<Feature> CalculateDragControlPointsCore(Feature feature)
{
Collection<Feature> returnFeatures = new Collection<Feature>();
if (!(string.Equals(feature.ColumnValues["ShapeType"], "RectangleShape") ||
string.Equals(feature.ColumnValues["ShapeType"], "EllipseShape")))
{
IEnumerable<Feature> features = base.CalculateDragControlPointsCore(feature);
foreach (Feature originalFeature in features)
{
returnFeatures.Add(originalFeature);
}
}
return returnFeatures;
}
protected override IEnumerable<Feature> CalculateResizeControlPointsCore(Feature feature)
{
Collection<Feature> returnFeatures = new Collection<Feature>();
if (string.Equals(feature.ColumnValues["ShapeType"], "RectangleShape") ||
string.Equals(feature.ColumnValues["ShapeType"], "EllipseShape"))
{
RectangleShape boundingBox = feature.GetBoundingBox();
returnFeatures.Add(new Feature(boundingBox.UpperLeftPoint));
returnFeatures.Add(new Feature(boundingBox.UpperRightPoint));
returnFeatures.Add(new Feature(boundingBox.LowerLeftPoint));
returnFeatures.Add(new Feature(boundingBox.LowerRightPoint));
}
else
{
IEnumerable<Feature> features = base.CalculateResizeControlPointsCore(feature);
foreach (Feature originalFeature in features)
{
returnFeatures.Add(originalFeature);
}
}
return returnFeatures;
}
protected override IEnumerable<Feature> CalculateRotateControlPointsCore(Feature feature)
{
Collection<Feature> returnFeatures = new Collection<Feature>();
if (!(string.Equals(feature.ColumnValues["ShapeType"], "RectangleShape") ||
string.Equals(feature.ColumnValues["ShapeType"], "EllipseShape")))
{
IEnumerable<Feature> features = base.CalculateRotateControlPointsCore(feature);
foreach (Feature originalFeature in features)
{
returnFeatures.Add(originalFeature);
}
}
return returnFeatures;
}
//Then in your application maybe in the Form_Load, you can write code like this:
private void Form1_Load(object sender, EventArgs e)
{
RectangleShape rectangleShape = new RectangleShape(-10, 10, 10, -10);
EllipseShape ellipseShape = new EllipseShape(new PointShape(20, 30), 10);
PolygonShape polygonShape = new PolygonShape("Polygon((20 -20,0 -30,10 -40,20 -20))");
winformsMap1.EditOverlay = new CustomerEditInteractiveOverlay();
winformsMap1.EditOverlay.EditShapesLayer.Open();
winformsMap1.EditOverlay.EditShapesLayer.Columns.Add(new FeatureSourceColumn("ShapeType"));
winformsMap1.EditOverlay.EditShapesLayer.Close();
Feature rectangleFeature = new Feature(rectangleShape.GetWellKnownBinary(), Guid.NewGuid().ToString(), new string[] { "ShapeType:RectangleShape" });
Feature ellipseFeature = new Feature(ellipseShape.GetWellKnownBinary(), Guid.NewGuid().ToString(), new string[] { "ShapeType:EllipseShape" });
Feature polygonFeature = new Feature(polygonShape.GetWellKnownBinary(), Guid.NewGuid().ToString(), new string[] { "ShapeType:PolygonShape" });
winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(rectangleFeature);
winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(ellipseFeature);
winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(polygonFeature);
winformsMap1.EditOverlay.CalculateAllControlPoints();
winformsMap1.CurrentExtent = new RectangleShape(-50, 50, 50, -50);
winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.None;
winformsMap1.Refresh();
}
Any more questions just let me know.
Thanks.
Yale