protected override InteractiveResult MouseUpCore(InteractionArguments interactionArguments) { if (IsShiftKeyDown == true) { PolygonShape newPolygonShape = (PolygonShape)EditShapesLayer.InternalFeatures[0].GetShape(); RingShape ringShape = new RingShape(); foreach (Feature feature in controlPoints) { PointShape controlPointShape = (PointShape)feature.GetShape(); if (feature.ColumnValues["nodetype"] == "special") { BaseShape baseShape = snappingFeature.GetShape(); PointShape pointShape = baseShape.GetClosestPointTo(controlPointShape, GeographyUnit.DecimalDegree); ringShape.Vertices.Add(new Vertex(pointShape.X, pointShape.Y)); } else { ringShape.Vertices.Add(new Vertex(controlPointShape.X, controlPointShape.Y)); } } newPolygonShape.OuterRing = ringShape; Feature newFeature = new Feature(newPolygonShape, EditShapesLayer.InternalFeatures[0].ColumnValues); EditShapesLayer.Open(); EditShapesLayer.EditTools.BeginTransaction(); EditShapesLayer.InternalFeatures.Clear(); EditShapesLayer.InternalFeatures.Add(newFeature); EditShapesLayer.EditTools.CommitTransaction(); EditShapesLayer.Close(); } return(base.MouseUpCore(interactionArguments)); }
//Overrides the DrawCore function. protected override void DrawCore(GeoCanvas canvas) { //Draws the Edit Shapes as default. Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); EditShapesLayer.Open(); EditShapesLayer.Draw(canvas, labelsInAllLayers); canvas.Flush(); //Draws the control points. ExistingControlPointsLayer.Open(); Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); //Loops thru the control points. foreach (Feature feature in controlPoints) { //Looks at the value of "state" to draw the control point as dragged or not. if (feature.ColumnValues["state"] != "selected") { Feature[] features = new Feature[1] { feature }; controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } else { Feature[] features = new Feature[1] { feature }; draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); PointShape pointShape = feature.GetShape() as PointShape; PointShape closestPointShape = referenceShape.GetClosestPointTo(pointShape, GeographyUnit.DecimalDegree); //Draws the closest point on the reference shape and the distance to it from the dragged control point. if (closestPointShape != null) { double Dist = System.Math.Round(closestPointShape.GetDistanceTo(pointShape, GeographyUnit.DecimalDegree, DistanceUnit.Meter)); ScreenPointF ScreenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, pointShape, canvas.Width, canvas.Height); canvas.DrawTextWithScreenCoordinate(System.Convert.ToString(Dist) + " m", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.Black), ScreenPointF.X + 35, ScreenPointF.Y, DrawingLevel.LabelLevel); canvas.DrawEllipse(closestPointShape, 12, 12, new GeoSolidBrush(GeoColor.StandardColors.Purple), DrawingLevel.LevelFour); } } } }