private void TrackAndEditShapes_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay(); winformsMap1.Overlays.Add(worldMapKitDesktopOverlay); winformsMap1.TrackOverlay = new MyInteractiveOverLay(); winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2); winformsMap1.Refresh(); } class MyInteractiveOverLay : TrackInteractiveOverlay { public MyInteractiveOverLay() : base() { } public void MouseDoubleClick() { base.MouseDoubleClickCore(new InteractionArguments()); } public void MouseDown(InteractionArguments interactionArguments) { base.MouseDownCore(interactionArguments); } } private void button_Click(object sender, EventArgs e) { Button button = sender as Button; if (button != null) { switch (button.Name) { case "btnTrackNormal": (winformsMap1.TrackOverlay as MyInteractiveOverLay).MouseDoubleClick(); switch (winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures[0].GetWellKnownType()) { case WellKnownType.Line: LineShape lineShape = winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures[0].GetShape() as LineShape; lineShape.Vertices.RemoveAt(lineShape.Vertices.Count - 1); winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures[0].WellKnownBinary = lineShape.GetWellKnownBinary(); foreach (Vertex vertex in lineShape.Vertices) { (winformsMap1.TrackOverlay as MyInteractiveOverLay).MouseDown(new InteractionArguments(){WorldX=vertex.X,WorldY=vertex.Y}); } winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); break; } winformsMap1.Refresh(); break; case "btnTrackPoint": winformsMap1.TrackOverlay.TrackMode = TrackMode.Point; break; case "btnTrackLine": winformsMap1.TrackOverlay.TrackMode = TrackMode.Line; break; case "btnTrackRectangle": winformsMap1.TrackOverlay.TrackMode = TrackMode.Rectangle; break; case "btnTrackSquare": winformsMap1.TrackOverlay.TrackMode = TrackMode.Square; break; case "btnTrackPolygon": winformsMap1.TrackOverlay.TrackMode = TrackMode.Polygon; break; case "btnTrackCircle": winformsMap1.TrackOverlay.TrackMode = TrackMode.Circle; break; case "btnTrackEllipse": winformsMap1.TrackOverlay.TrackMode = TrackMode.Ellipse; break; case "btnTrackEdit": winformsMap1.TrackOverlay.TrackMode = TrackMode.None; foreach (Feature feature in winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures) { winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature); } winformsMap1.EditOverlay.CalculateAllControlPoints(); winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); winformsMap1.Refresh(new Overlay[] { winformsMap1.EditOverlay, winformsMap1.TrackOverlay }); break; case "btnTrackDelete": int lastIndex = winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Count - 1; if (lastIndex >= 0) { winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.RemoveAt(lastIndex); winformsMap1.EditOverlay.CalculateAllControlPoints(); } winformsMap1.Refresh(winformsMap1.EditOverlay); break; default: winformsMap1.TrackOverlay.TrackMode = TrackMode.None; break; } } }