private void MapControl_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (isEnable && isStarted) { IsEnable = false; this.toolTip.Active = false; isStarted = false; if (DrawComplete != null) { List <LineMarker> lineMarkers = new List <LineMarker>(); List <DrawDistanceMarker> distanceMarkers = new List <DrawDistanceMarker>(); foreach (GMapMarker marker in tempOverlay.Markers) { if (marker is LineMarker) { LineMarker line = marker as LineMarker; lineMarkers.Add(new LineMarker(line.startPoint, line.endPoint)); } if (marker is DrawDistanceMarker) { DrawDistanceMarker distanceMarker = marker as DrawDistanceMarker; distanceMarkers.Add(new DrawDistanceMarker(distanceMarker.Position, distanceMarker.ToolTipText)); } } DrawComplete(this, new DrawDistanceEventArgs(lineMarkers, distanceMarkers)); } ClearTempDrawing(); } }
private void MapControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left && !isStarted && isEnable) { isStarted = true; this.toolTip.Active = true; PointLatLng p = MapControl.FromLocalToLatLng(e.X, e.Y); DrawDistanceMarker marker = new DrawDistanceMarker(p, "起点"); tempOverlay.Markers.Add(marker); lastPointLatLng = p; tempLine = new TempLineMarker(p, p); tempOverlay.Markers.Add(tempLine); } else if (e.Button == MouseButtons.Left && isStarted && isEnable) { PointLatLng p = MapControl.FromLocalToLatLng(e.X, e.Y); double x = p.Lng - lastPointLatLng.Lng; double y = p.Lat - lastPointLatLng.Lat; double dis = GMapHelper.GetDistanceInMeter(p, lastPointLatLng); distanceList.Add(dis); double sum = distanceList.Sum(); string s = string.Format("{0:0.00}米", sum); DrawDistanceMarker marker = new DrawDistanceMarker(p, s); tempOverlay.Markers.Add(marker); LineMarker line = new LineMarker(new PointLatLng(lastPointLatLng.Lat, lastPointLatLng.Lng), p); tempOverlay.Markers.Add(line); if (tempOverlay.Markers.Contains(tempLine)) { tempOverlay.Markers.Remove(tempLine); } tempLine = new TempLineMarker(p, p); tempOverlay.Markers.Add(tempLine); lastPointLatLng = p; } }