private void DisplayMap_Load(object sender, EventArgs e) { winformsMap1.MouseClick += new MouseEventHandler(winformsMap1_MouseClick); winformsMap1.MouseWheel += new MouseEventHandler(winformsMap1_MouseWheel);//add new waypoints at the start, in the middle, and at the end of route/line afterwards winformsMap1.MouseDoubleClick += new MouseEventHandler(winformsMap1_MouseDoubleClick);//click on a leg (line between two waypoints) and choose whether it should be drawn as rhumb line or great circle winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.CurrentExtent = new RectangleShape(-80, 80, 80, -80); WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay(); winformsMap1.Overlays.Add(worldMapKitDesktopOverlay); winformsMap1.EditOverlay = editOverlay; trackOverlay.TrackEnded += new EventHandler(interactiveOverlay_TrackEnded); trackOverlay.TrackMode = TrackMode.None; winformsMap1.TrackOverlay = trackOverlay; winformsMap1.Refresh(); } void winformsMap1_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (trackOverlay.TrackMode == TrackMode.None && editOverlay.EditShapesLayer.InternalFeatures.Count > 0) { RhumbLineAndGreatCircleSwitch(e); } } } void winformsMap1_MouseWheel(object sender, MouseEventArgs e) { LineShape lineshape = editOverlay.EditShapesLayer.InternalFeatures[0].GetShape() as LineShape; lineshape.Vertices.Add(new Vertex(0, 0)); editOverlay.EditShapesLayer.InternalFeatures[0] = new Feature(lineshape); editOverlay.CalculateAllControlPoints(); } void interactiveOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e) { trackOverlay.TrackMode = TrackMode.None; trackOverlay.TrackShapeLayer.InternalFeatures.Clear(); editOverlay.EditShapesLayer.InternalFeatures.Add(new Feature(e.TrackShape)); editOverlay.CalculateAllControlPoints(); rhumbLineShape = editOverlay.EditShapesLayer.InternalFeatures[0].GetShape() as LineShape; } EditInteractiveOverlay editOverlay = new EditInteractiveOverlay(); TrackInteractiveOverlay trackOverlay = new TrackInteractiveOverlay(); LineShape rhumbLineShape; void winformsMap1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (trackOverlay.TrackMode == TrackMode.None) { trackOverlay.TrackMode = TrackMode.Line; } else { trackOverlay.TrackMode = TrackMode.None; }; } } private void RhumbLineAndGreatCircleSwitch(MouseEventArgs e) { LineShape lineshape = editOverlay.EditShapesLayer.InternalFeatures[0].GetShape() as LineShape; for (int i = 0; i < lineshape.Vertices.Count - 1; i++) { Collection vertices = new Collection(); vertices.Add(lineshape.Vertices[i]); vertices.Add(lineshape.Vertices[i + 1]); MultipolygonShape bufferedLineShape = (new LineShape(vertices)).Buffer(1000, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer); if (bufferedLineShape.Contains(ExtentHelper.ToWorldCoordinate(new RectangleShape(-80, 80, 80, -80), e.X, e.Y, winformsMap1.Width, winformsMap1.Height)))//if the trackline is clicked { LineShape newLineShape = new LineShape(); if (MessageBox.Show("Please Choose RhumbLine Or GreatCircle", "gg", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes) { PointShape startPointOfCircle = new PointShape(vertices[0]); MultilineShape Circle = startPointOfCircle.GreatCircle(new PointShape(vertices[1])); for (int n = 0; n < i; n++) { newLineShape.Vertices.Add(lineshape.Vertices[n]); } foreach (Vertex vertice in Circle.Lines[0].Vertices) { newLineShape.Vertices.Add(vertice); } for (int n = i + 2; n < lineshape.Vertices.Count; n++) { newLineShape.Vertices.Add(lineshape.Vertices[n]); } } else { newLineShape = rhumbLineShape; } editOverlay.EditShapesLayer.InternalFeatures[0] = new Feature(newLineShape); winformsMap1.Refresh(editOverlay); break; } } }