private void 更改半径ToolStripMenuItem_Click(object sender, EventArgs e) { if (circleElement == null) { return; } circleElement.UpdatePosition(300000); }
/// <summary> /// 编辑点移动事件 /// </summary> /// <param name="element"></param> /// <param name="e"></param> void editPoint_MarkerMouseMoveEvent(IElement element, IMapControlEvents2_OnMouseMoveEvent e) { IPoint newPoint = new PointClass(); var mapPoint = new MapFrame.Core.Model.MapLngLat() { Lng = e.mapX, Lat = e.mapY }; newPoint.PutCoords(e.mapX, e.mapY); if (isControlDown) { centerMarker.MoveTo(newPoint);//圆心点也跟着移动 circleArcMap.UpdatePosition(mapPoint); int i = 0; for (float ang = 0; ang <= 270; ang += 90) { var point = GetPointByDistanceAndAngle(circleArcMap.GetRadius() * 100000, newPoint, ang); markerList[i].MoveTo(point); i++; } } else { if (currentMarker.Name == "s") { currentMarker.MoveTo(newPoint); circleArcMap.UpdatePosition(mapPoint); int i = 0; for (float ang = 0; ang <= 270; ang += 90) { var point = GetPointByDistanceAndAngle(circleArcMap.GetRadius(), newPoint, ang); markerList[i].MoveTo(point); i++; } } else { IPoint centerDot = new PointClass() { X = circleArcMap.GetCenterDot().Lng, Y = circleArcMap.GetCenterDot().Lat }; double radius = MapFrame.Core.Common.Utils.GetDistance(circleArcMap.GetCenterDot(), mapPoint); circleArcMap.UpdatePosition(radius); int i = 0; for (float ang = 0; ang <= 270; ang += 90) { var point = GetPointByDistanceAndAngle(radius, centerDot, ang); markerList[i].MoveTo(point); i++; } } mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, circleElement, null); } currentPoint = new PointClass(); currentPoint.PutCoords(e.mapX, e.mapY); }
/// <summary> /// 鼠标移动事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { if (isMouseDown && !isControl) { double circleRadius = MapFrame.Core.Common.Utils.GetDistance(centerDot, new MapLngLat(e.mapX, e.mapY)); circleElement.UpdatePosition(circleRadius); } }
// 鼠标移动事件 private void gmapControl_MouseMove(object sender, MouseEventArgs e) { if (isLeftButtonDown == false) { return; } if (bOnMarkerEnter == true) { bOnMarkerEnter = false; gmapControl.OnMarkerEnter -= gmapControl_OnMarkerEnter; } if (bOnMarkerLeave == true) { bOnMarkerLeave = false; gmapControl.OnMarkerLeave -= gmapControl_OnMarkerLeave; } if (editType == 0) { var lngLat = gmapControl.FromLocalToLatLng(e.X, e.Y); circleMarker.Position = lngLat; gmapControl.Cursor = Cursors.SizeAll; // 实时更新圆心坐标 centerPoint = circleMarker.Position; } else if (editType == 1) { if (currentEditPoint == null || currIndex == -1) { return; } var lngLat = gmapControl.FromLocalToLatLng(e.X, e.Y); if (currIndex == 0 || currIndex == 2) { lngLat.Lng = currentEditPoint.Position.Lng; } else if (currIndex == 1 || currIndex == 3) { lngLat.Lat = currentEditPoint.Position.Lat; } currentEditPoint.Position = lngLat; double distance = gmapControl.MapProvider.Projection.GetDistance(centerPoint, lngLat) * 1000; circleMarker.Position = centerPoint; circleElement.UpdatePosition(distance); gmapControl.UpdateMarkerLocalPosition(circleMarker); // 实时更新半径 radius = distance; } RemoveEditMarker(); AddEditMarker(); }
// 移动鼠标实时绘制圆 private void gmapControl_MouseMove(object sender, MouseEventArgs e) { if (!drawn) { return; } movePoint.Lng = gmapControl.FromLocalToLatLng(e.X, e.Y).Lng; movePoint.Lat = gmapControl.FromLocalToLatLng(e.X, e.Y).Lat; this.radius = MapFrame.Core.Common.Utils.GetDistance(centerPoint, movePoint) * 1000; circleElement.UpdatePosition(this.radius); }
//鼠标移动事件 private void mapControl_MouseMove(object sender, MouseEventArgs e) { PointLatLng pointLatLng = mapControl.FromLocalToLatLng(e.X, e.Y); MapLngLat lnglat = new MapLngLat(pointLatLng.Lng, pointLatLng.Lat); if (e.Button != MouseButtons.Left) { return; } switch (editType) { case 0: //修改大小 randomMarker.IsVisible = true; randomMarker.Position = pointLatLng; double radius = Utils.GetDistance(circleElement.GetCenterDot(), lnglat) * 1000; circleElement.UpdatePosition(radius); break; case 1: //更新圆心 randomMarker.IsVisible = false; circleElement.UpdatePosition(lnglat); break; } }
// 处理波束数据 private void DealBeamCover(BeamData e) { if (e.Point.Alt > 0) { return; // 卫星数据,不做处理 } if (mapLogic == null) { return; } // 添加圆图元(波束覆盖) IMFLayer layer = mapLogic.AddLayer(coverLayerName); if (layer == null) { return; } string circleName = string.Format("卫星{0}-波束{1}", e.SatelliteId, e.BeamId); string textName = string.Format("卫星{0}-波束{1}_描述", e.SatelliteId, e.BeamId, e.BeamId); if (!beamDic.ContainsKey(e.SatelliteId)) // 新的波束 { Kml kmlCircle = new Kml(); kmlCircle.Placemark.Name = circleName; KmlCircle circle = new KmlCircle(); circle.Position = e.Point; circle.FillColor = Color.FromArgb(50, Color.Green); circle.Radius = 500000; circle.StrokeColor = Color.Blue; circle.StrokeWidth = 1; kmlCircle.Placemark.Graph = circle; layer.AddElement(kmlCircle); // 添加文字图元 Kml kmlText = new Kml(); kmlText.Placemark.Name = textName; string context = string.Format("卫星{0}-波束{1}", e.SatelliteId, e.BeamId); kmlText.Placemark.Graph = new KmlText() { Position = e.Point, Content = context, Color = Color.Blue, Font = "宋体", Size = 10 }; IMFElement elementText; if (layer.AddElement(kmlText, out elementText)) { bool visible = zoom >= visibleZoom ? true : false; elementText.SetVisible(visible); } // 添加到字典进行维护 List <int> beamIdList = new List <int>(); beamIdList.Add(e.BeamId); lock (beamDic) { beamDic.Add(e.SatelliteId, beamIdList); } } else { if (!beamDic[e.SatelliteId].Contains(e.BeamId)) // 新的波束 { Kml kmlCircle = new Kml(); kmlCircle.Placemark.Name = circleName; KmlCircle circle = new KmlCircle(); circle.Position = e.Point; circle.FillColor = Color.FromArgb(50, Color.Green); circle.Radius = 500000; circle.StrokeColor = Color.Blue; circle.StrokeWidth = 1; kmlCircle.Placemark.Graph = circle; layer.AddElement(kmlCircle); // 添加文字图元 string context = string.Format("卫星{0}-波束{1}", e.SatelliteId, e.BeamId); Kml kmlText = new Kml(); kmlText.Placemark.Name = textName; kmlText.Placemark.Graph = new KmlText() { Position = e.Point, Content = context, Color = Color.Blue, Font = "宋体", Size = 10 }; IMFElement elementText; if (layer.AddElement(kmlText, out elementText)) { bool visible = zoom >= visibleZoom ? true : false; elementText.SetVisible(visible); } lock (beamDic) { // 添加到字典进行维护 beamDic[e.SatelliteId].Add(e.BeamId); } } else { // 更新圆图元(波束覆盖)位置 IMFElement elementCircle = layer.GetElement(circleName); if (elementCircle != null) { IMFCircle circle = elementCircle as IMFCircle; if (circle != null) { circle.UpdatePosition(e.Point); } } // 更新文字图元(描述信息)位置 IMFElement elementText = layer.GetElement(textName); if (elementText != null) { IMFText text = elementText as IMFText; if (text != null) { text.UpdatePosition(e.Point); } } } } }