ThinkGeo.com    |     Documentation    |     Premium Support

How to chang Resize Control Point appearance

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
    }


Greg, 
  
   Add the code below in the constructor.  You can set the style of the control points just like you do with any of our other layers.  This is really handy as you can easily control the look and feel of all of the control points we use.  You can make them change at different zoom levels or not draw at all etc.  Very powerful, let me know if you have any additional questions. 
  
            ResizeControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 12); 
             ResizeControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
  
 David

Hi David,  thanks for the reply.  Works great!


-Greg



Greg, 
  
 Glad you liked it.  Remeber you have allot of control on the rendering. 
  
 David