private void TheMap_MouseMove(object sender, MouseEventArgs e) { PointLatLng point = TheMap.FromLocalToLatLng(e.X, e.Y); lblCoords.Text = _Dh.getLatitude(point) + " " + _Dh.getLongitude(point); //polygon.Points[2] = polygon.Points[4]; //TheMap.UpdatePolygonLocalPosition(polygon); if (e.Button == MouseButtons.Left && isMouseDown && isEditMode) { // Show on map the change of position if (wObject != null) { int index = Convert.ToInt32(wMarker.Tag); switch (_Dh.getGroupById(wObject.ObGroupId).GroupType) { case ObjectType.POLYGON: wMarker.Position = point; wObject.Polygon.Points[index] = wMarker.Position; TheMap.UpdatePolygonLocalPosition(wObject.Polygon); break; case ObjectType.ROUTE: wMarker.Position = point; wObject.Route.Points[index] = wMarker.Position; TheMap.UpdateRouteLocalPosition(wObject.Route); break; case ObjectType.DOT: wObject.Marker.Position = point; break; } } } }
private void TheMap_MouseUp(object sender, MouseEventArgs e) { isMouseDown = false; if (e.Button == MouseButtons.Left && isEditMode) { if (wObject != null) { if (System.Windows.Forms.Application.OpenForms["frmObjInfo"] != null) { (System.Windows.Forms.Application.OpenForms["frmObjInfo"] as FrmObjInfo).RefreshUI(Convert.ToInt32(wMarker.Tag), TheMap.FromLocalToLatLng(e.X, e.Y)); } } } }
private void TheMap_MouseClick(object sender, MouseEventArgs e) { /* Don't use those, 'cause no one uses! * Recalculate gRecalculations = new Recalculate(); * var lat = gRecalculations.SK42_WGS84_Lat(point.Lat, point.Lng, 0); * var lng = gRecalculations.WGS84_SK42_Long(point.Lat, point.Lng, 0); */ // MessageBox.Show(GeoAngle.FromDouble(point.Lat).ToString() + "\r\n" + GeoAngle.FromDouble(point.Lng).ToString()); if (isbtnNewObjectClicked) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { switch (currentGroup.GroupType) { case ObjectType.DOT: { cmbObGroups.Enabled = true; GMarkerGoogle marker; PointLatLng point = TheMap.FromLocalToLatLng(e.X, e.Y); if (currentGroup.Appendix.Length > 5) { Bitmap bmp; using (var ms = new MemoryStream(Convert.FromBase64String(currentGroup.Appendix))) { bmp = new Bitmap(ms); } marker = new GMarkerGoogle(point, bmp); } else { marker = new GMarkerGoogle(point, GMarkerGoogleType.green); } TheMap.Overlays[cmbObGroups.SelectedIndex].Markers.Add(marker); TheMap.UpdateMarkerLocalPosition(marker); isbtnNewObjectClicked = false; GeoCoderStatusCode status; var fObjInfo = new FrmObjInfo(new xObject() { Coordinates = new List <PointLatLng>() { point }, ObGroupId = currentGroup.Id, C_Date = _Dh.rightNow, Placemark = GMapProviders.OpenStreet4UMap.GetPlacemark(point, out status).Value.Address }); if (fObjInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { MarkerTooltipMode mode = MarkerTooltipMode.Always; marker.ToolTip = new GMapBaloonToolTip(marker); marker.ToolTipMode = mode; Brush ToolTipBackColor = new SolidBrush(Color.Transparent); marker.ToolTipText = wObject.Name; wObject.Marker = marker; } RefreshUI(); break; } case ObjectType.ROUTE: { somePoints.Add(TheMap.FromLocalToLatLng(e.X, e.Y)); _Dh.getOverlay(TheMap, currentGroup).Markers.Add(new GMarkerCross(TheMap.FromLocalToLatLng(e.X, e.Y)) { IsVisible = true, ToolTipMode = MarkerTooltipMode.Always }); recycleIndexes.Add(_Dh.getOverlay(TheMap, currentGroup).Markers.Count - 1); break; } case ObjectType.POLYGON: { somePoints.Add(TheMap.FromLocalToLatLng(e.X, e.Y)); GMapOverlay ov = _Dh.getOverlay(TheMap, currentGroup); ov.Markers.Add(new GMarkerCross(TheMap.FromLocalToLatLng(e.X, e.Y)) { IsVisible = true, ToolTipMode = MarkerTooltipMode.Always }); recycleIndexes.Add(_Dh.getOverlay(TheMap, currentGroup).Markers.Count - 1); break; } } } if (e.Button == System.Windows.Forms.MouseButtons.Right) { DialogResult dr = _Dh.msgQuestion("Закончить выбор точек?"); if (dr == DialogResult.Yes) { cmbObGroups.Enabled = true; isbtnNewObjectClicked = false; if (currentGroup.GroupType == ObjectType.ROUTE) { newRoute(); } if (currentGroup.GroupType == ObjectType.POLYGON) { newPolygon(); } } } } }