Ejemplo n.º 1
0
        protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
        {
            // Override the base method and modify the logic for resizing if the shape is the "custom"
            if (sourceFeature.ColumnValues.ContainsKey("Edit") && sourceFeature.ColumnValues["Edit"] == "rectangle")
            {
                PolygonShape polygonShape = sourceFeature.GetShape() as PolygonShape;

                if (polygonShape != null)
                {
                    // If the rectangle is horizontal or vertical, it will use the custom method.
                    if (string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText()))
                    {
                        int fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint);

                        PointShape fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]);

                        RectangleShape newRectangleShape = new LineShape(new Vertex[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox();

                        return(new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues));
                    }
                }
            }

            return(base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint));
        }