/// <summary> /// 左键弹起 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void mapControl_eventLButtonUp(object sender, _DHOSOFTMapControlEvents_eventLButtonUpEvent e) { //if (!isShift) //{ // isFinish = true; // isMouseDown = false; // RegistCommondExecutedEvent(); //} if (!isControl) { if (!string.IsNullOrEmpty(tempName)) { mapControl.MgsDelObject(tempName); } Kml kml = new Kml(); KmlCircle circle = new KmlCircle(); kml.Placemark.Name = "mgis_circle" + Utils.ElementIndex; circle.Position = centerPoint; circle.RandomPosition = new MapLngLat(e.dLong, e.dLat); circle.StrokeColor = System.Drawing.Color.Red; circle.FillColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.White); circle.StrokeWidth = 3; kml.Placemark.Graph = circle; IMFElement element = null; layer.AddElement(kml, out element); circleElement = element as IMFCircle; RegistCommondExecutedEvent(); ReleaseCommond();//修改 陈静 isFinish = true; isMouseDown = false; } }
// 鼠标左键按下 private void gmapControl_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && !gmapControl.CanDragMap)//空格按下后漫游 { var lngLat = gmapControl.FromLocalToLatLng(e.X, e.Y); centerPoint.Lng = lngLat.Lng; centerPoint.Lat = lngLat.Lat; Kml kml = new Kml(); kml.Placemark.Name = "draw_circle" + Utils.ElementIndex; KmlCircle circleKml = new KmlCircle(); circleKml.FillColor = Color.FromArgb(50, Color.Blue); circleKml.Position = new MapLngLat(lngLat.Lng, lngLat.Lat); circleKml.RandomPosition = circleKml.Position; circleKml.Radius = 0; circleKml.StrokeColor = Color.Gray; circleKml.StrokeWidth = 2; kml.Placemark.Graph = circleKml; IMFElement element = null; drawn = layer.AddElement(kml, out element); circleElement = element as IMFCircle; gmapControl.MouseMove += gmapControl_MouseMove; gmapControl.MouseUp += gmapControl_MouseUp; } }
// 设置设备显示、隐藏 public void SetDeviceVisible(string deviceName, bool visible) { IMFLayer layer = mapLogic.GetLayer("设备服务图层"); if (layer == null) { return; } IMFElement element = layer.GetElement(deviceName); if (element != null) { IMFPicture picture = element as IMFPicture; if (picture != null) { picture.SetVisible(visible); } } IMFElement ele = layer.GetElement(deviceName + "polygon"); if (ele != null) { IMFCircle circle = ele as IMFCircle; if (circle != null) { circle.SetVisible(visible); } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="_mapControl">地图控件</param> /// <param name="element">图元</param> public EditCircle(AxMapControl _mapControl, IMFElement element) { mapControl = _mapControl; markerList = new List <EditMarker>(); circleElement = element as CircleElementClass; circleArcMap = circleElement as Circle_ArcMap; }
/// <summary> /// 释放 /// </summary> public void Dispose() { ReleaseCommond(); mapControl = null; CommondExecutedEvent = null; circleElement = null; overlay = null; }
/// <summary> /// 构造函数 /// </summary> /// <param name="_gmapControl">地图控件</param> /// <param name="_element">图元</param> public EditCircle(GMapControl _gmapControl, IMFElement _element) { gmapControl = _gmapControl; circleMarker = _element as GMapMarker; this.circleElement = _element as IMFCircle; circleElement = _element as IMFCircle; listPoints = new List <PointLatLng>(); }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { mapControl = null; mapLogic = null; isFinish = false; isControl = false; circleElement = null; centerPoint = null; layer = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { ReleaseCommond(); CommondExecutedEvent = null; gmapControl = null; mapLogic = null; centerPoint = null; movePoint = null; circleElement = null; layer = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { ReleaseCommond(); CommondExecutedEvent = null; gmapControl = null; circleMarker = null; isLeftButtonDown = false; currentEditPoint = null; overlay = null; circleElement = null; listPoints = null;//存储坐标点 }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { circleElement = null; CommondExecutedEvent = null; layer = null; currentMarker = null; currentPoint = null; circleArcMap = null; markerList = null; centerMarker = null; mapControl = null; mapLogic = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { ReleaseCommond(); CommondExecutedEvent = null; mapControl = null; mapLogic = null; centerDot = null; circleElement = null; isFinish = false; isMouseDown = false; isControl = false; layer = null; }
private void 添加圆ToolStripMenuItem_Click(object sender, EventArgs e) { Kml kml = new Kml(); kml.Placemark.Name = "my_circle"; KmlCircle circle = new KmlCircle(); circle.Position = new MapLngLat(110, 30); circle.FillColor = Color.Red; circle.Radius = 500000; circle.StrokeColor = Color.Gray; circle.StrokeWidth = 3; kml.Placemark.Graph = circle; // 画点 mapLogic.GetLayer(drawLayerName).AddElement(kml, out element); circleElement = element as IMFCircle; }
private void SetGMapElementColor(string layerName, string elementName, Color color) { var layer = mapBusiness.mapLogic.GetLayer(layerName); if (layer == null) { return; } var ele = layer.GetElement(elementName); if (ele == null) { return; } IMFCircle circle = ele as IMFCircle; if (circle == null) { return; } circle.SetFillColor(color); }
/// <summary> /// 鼠标按下事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (e.button == 1 && !isMouseDown && !isControl) { centerDot = new MapLngLat() { Lng = e.mapX, Lat = e.mapY }; Kml kml = new Kml(); kml.Placemark.Name = "arc_circle" + Utils.ElementIndex; KmlCircle circle = new KmlCircle(); circle.Position = centerDot; circle.Radius = 0.1; circle.StrokeColor = Color.Yellow; circle.StrokeWidth = 2; circle.FillColor = System.Drawing.Color.Red; kml.Placemark.Graph = circle; IMFElement element = null; layer.AddElement(kml, out element); circleElement = element as IMFCircle; isMouseDown = true; isFinish = false; } }
// 处理波束数据 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); } } } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="_gmapControl"></param> /// <param name="_element"></param> public EditCircleEx(GMapControl _gmapControl, IMFElement _element) { this.mapControl = _gmapControl; this.circleElement = _element as IMFCircle; overlay = new GMapOverlay("draw_layer"); }
void Form1_CommondExecutedEvent(object sender, MessageEventArgs e) { switch (e.ToolType) { case ToolTypeEnum.Draw: element = e.Data as IMFElement; switch (element.ElementType) { case ElementTypeEnum.Circle: circleElement = element as IMFCircle; break; case ElementTypeEnum.Point: pointElement = element as IMFPoint; break; case ElementTypeEnum.Line: lineElement = element as IMFLine; double length = lineElement.GetDistance(); break; case ElementTypeEnum.Polygon: polygonElement = element as IMFPolygon; double area = polygonElement.GetArea(); break; case ElementTypeEnum.Text: textElement = element as IMFText; break; case ElementTypeEnum.Rectangle: rectangleElement = element as IMFPolygon; break; } break; case ToolTypeEnum.Measure: break; case ToolTypeEnum.Select: List <IMFElement> elements = (sender as IMFSelect).GetSelectElements(); break; case ToolTypeEnum.Edit: switch (element.ElementType) { case ElementTypeEnum.Point: pointElement = element as IMFPoint; break; case ElementTypeEnum.Line: lineElement = element as IMFLine; double length = lineElement.GetDistance(); break; case ElementTypeEnum.Polygon: polygonElement = element as IMFPolygon; double area = polygonElement.GetArea(); break; case ElementTypeEnum.Text: textElement = element as IMFText; break; } break; } }