Hi,
We are playing around with a custom EditInteractiveOverlay, and we're close to having something that fits our requirements. The next piece for us is to change the appearance of the resize control points to a simple dot, instead of the current circle with an arrow. Is there an easy way to do this with the code below?
Thanks,
Greg
public class RectangularEditInteractiveOverlay : EditInteractiveOverlay
{
private ResizeMode resizeMode;
public RectangularEditInteractiveOverlay()
{
ResizeMode = ResizeMode.OnePointFixed;
DragControlPointsLayer.DrawingQuality = DrawingQuality.HighSpeed;
RotateControlPointsLayer.DrawingQuality = DrawingQuality.HighSpeed;
}
public ResizeMode ResizeMode
{
get { return resizeMode; }
set { resizeMode = value; }
}
protected override Feature AddVertexCore(Feature targetFeature, PointShape targetPointShape, double searchingTolerance)
{
return new Feature();
}
protected override IEnumerable<Feature> CalculateResizeControlPointsCore(Feature feature)
{
Collection<Feature> resizeControlPoints = new Collection<Feature>();
PolygonShape polygonShape = feature.GetShape() as PolygonShape;
if (polygonShape != null) {
foreach (Vertex vertex in polygonShape.OuterRing.Vertices) {
resizeControlPoints.Add(new Feature(vertex, feature.Id));
}
}
return resizeControlPoints;
}
protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
{
Feature editedFeature = new Feature();
PolygonShape polygonShape = sourceFeature.GetShape() as PolygonShape;
int fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint);
PointShape fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]);
if (resizeMode == ResizeMode.OnePointFixed) {
RectangleShape newRectangleShape = new LineShape(new Vertex[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox();
editedFeature = new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues);
if (!string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText())) {
editedFeature = base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint);
}
} else {
editedFeature = base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint);
}
return editedFeature;
}
private int GetFixedPointIndex(PolygonShape sourcePolygonShape, PointShape sourceControlPointShape)
{
int index = 0;
for (int i = 0; i < sourcePolygonShape.OuterRing.Vertices.Count; i++) {
Vertex vertex = sourcePolygonShape.OuterRing.Vertices[i];
if (Math.Abs(vertex.X - sourceControlPointShape.X) <= 10E-6 && Math.Abs(vertex.Y - sourceControlPointShape.Y) <= 10E-6) {
index = i;
break;
}
}
int fixedPointIndex = 0;
if (index <= 2) {
fixedPointIndex = index + 2;
} else {
fixedPointIndex = index - 2;
}
return fixedPointIndex;
}
}
public enum ResizeMode
{
Default = 0,
Standard = 1,
OnePointFixed = 2
}