Exemple #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_gmapControl">地图控件</param>
 /// <param name="_element">图元</param>
 public EditLine(GMapControl _gmapControl, IMFElement _element)
 {
     gmapControl = _gmapControl;
     route       = _element as GMapRoute;
     element     = _element;
     pointList   = new List <Point_GMap>();
 }
Exemple #2
0
        // 鼠标按下事件,
        private void gmapControl_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                bIsLeftButtonDown = true;
                if (bIsMultiSelect == false)
                {
                    return;
                }

                PointLatLng point = gmapControl.FromLocalToLatLng(e.X, e.Y);
                currentPoint = new MapLngLat(point.Lng, point.Lat);
                pointList[0] = currentPoint;
                Kml polygonKml = new Kml();
                polygonKml.Placemark.Name = "select_rect";

                List <MapLngLat> pList = new List <MapLngLat>();
                pList.Add(new MapLngLat(point.Lng, point.Lat));
                pList.Add(new MapLngLat(point.Lng, point.Lat));
                pList.Add(new MapLngLat(point.Lng, point.Lat));
                pList.Add(new MapLngLat(point.Lng, point.Lat));

                polygonKml.Placemark.Graph = new KmlPolygon()
                {
                    Description  = "框框",
                    FillColor    = Color.FromArgb(20, Color.Blue),
                    OutLineColor = Color.Blue,
                    PositionList = pList
                };
                IMFElement element = null;
                bool       f       = layer.AddElement(polygonKml, out element);
                polygonElement = element as IMFPolygon;
            }
        }
Exemple #3
0
        /// <summary>
        /// 鼠标弹起结束绘制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_eventLButtonUp(object sender, _DHOSOFTMapControlEvents_eventLButtonUpEvent e)
        {
            if (!isControl)
            {
                MapLngLat p1 = new MapLngLat(e.dLong, listPoints[0].Lat);
                MapLngLat p2 = new MapLngLat(e.dLong, e.dLat);
                MapLngLat p3 = new MapLngLat(listPoints[0].Lng, e.dLat);
                listPoints.Add(p1);
                listPoints.Add(p2);
                listPoints.Add(p3);

                if (!string.IsNullOrEmpty(tempName))
                {
                    mapControl.MgsDelObject(tempName);
                }
                Kml        kml       = new Kml();
                KmlPolygon rectangle = new KmlPolygon();
                kml.Placemark.Name     = "mgis_rec" + Utils.ElementIndex;
                rectangle.PositionList = listPoints;
                rectangle.FillColor    = System.Drawing.Color.FromArgb(0, System.Drawing.Color.White);
                rectangle.OutLineColor = System.Drawing.Color.Red;
                rectangle.OutLineSize  = 3;
                kml.Placemark.Graph    = rectangle;
                IMFElement element = null;
                layer.AddElement(kml, out element);
                recElement = element as IMFPolygon;

                RegistCommondExecutedEvent();
                ReleaseCommond();//修改  陈静
                isFinish = true;
                listPoints.Clear();
            }
        }
Exemple #4
0
        /// <summary>
        /// 添加图元
        /// </summary>
        /// <param name="kml">kml对象</param>
        /// <returns></returns>
        public bool AddElement(Kml kml)
        {
            // 检查是否已经添加相同键的图元,如果有,则返回失败
            if (string.IsNullOrEmpty(kml.Placemark.Name))
            {
                return(false);
            }

            lock (_elementDic)
            {
                if (_elementDic.ContainsKey(kml.Placemark.Name))
                {
                    return(false);
                }
            }

            // 创建图元
            IMFElement element = _mapFactory.AddElement(LayerName, kml);

            // 如果图元创建失败,则返回失败
            if (element == null)
            {
                return(false);
            }
            // 设置图元所属图层
            element.BelongLayer = this;

            lock (_elementDic)
            {
                // 添加到字典
                _elementDic.Add(element.ElementName, element);
            }

            return(true);
        }
        // 设置设备显示、隐藏
        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);
                }
            }
        }
Exemple #6
0
        /// <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;
            }
        }
Exemple #7
0
        // 鼠标左键按下
        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;
            }
        }
Exemple #8
0
 /// <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;
 }
Exemple #9
0
 /// <summary>
 /// 鼠标按下开始绘制
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 1 && !isControl)
     {
         MapLngLat lngLat = new MapLngLat(e.mapX, e.mapY);
         if (listMapPoints.Count == 0)
         {
             listMapPoints.Add(lngLat);
             Kml kml = new Kml();
             kml.Placemark.Name = "arc_Polygon" + Utils.ElementIndex;
             Color outlineColor = Color.Blue;
             Color fillColor    = Color.Black;
             kml.Placemark.Graph = new KmlPolygon()
             {
                 FillColor = fillColor, OutLineColor = outlineColor, OutLineSize = 1, PositionList = listMapPoints
             };
             IMFElement element = null;
             layer.AddElement(kml, out element);
             polygonElement = element as IMFPolygon;
             isFinish       = false;//为不完成状态
         }
         else if (listMapPoints.Find(p => p.Lng == e.mapX && p.Lat == e.mapY) == null)
         {
             listMapPoints.Add(lngLat);
         }
     }
 }
Exemple #10
0
 /// <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)
     {
         //绘制矩形  四个点的位置集中在一个点上
         Kml kml = new Kml();
         kml.Placemark.Name = "arc_rectangle" + Utils.ElementIndex;
         KmlPolygon kmlRectangle = new KmlPolygon();
         kmlRectangle.Description  = "手动绘制的一个矩形";
         kmlRectangle.FillColor    = Color.Yellow;
         kmlRectangle.OutLineColor = Color.Black;
         kmlRectangle.OutLineSize  = 1;
         MapLngLat lnglat = new MapLngLat(e.mapX, e.mapY);
         pointList.Add(lnglat);
         pointList.Add(lnglat);
         pointList.Add(lnglat);
         pointList.Add(lnglat);
         kmlRectangle.PositionList = pointList;
         kml.Placemark.Graph       = kmlRectangle;
         IMFElement element = null;
         layer.AddElement(kml, out element);
         polygonElement = element as IMFPolygon;
         isMouseDown    = true;
         isFinish       = false;
     }
 }
Exemple #11
0
        /// <summary>
        /// 删除图元
        /// </summary>
        /// <param name="element"></param>
        /// <param name="layer"></param>
        /// <returns></returns>
        public bool RemoveElement(IMFElement element, ILayer layer)
        {
            if (element == null)
            {
                return(true);
            }
            IGraphicsContainer graphicsLayer = layer as IGraphicsContainer;

            if (graphicsLayer == null)
            {
                return(true);
            }

            Point_ArcGlobe pointElement = element as Point_ArcGlobe;

            if (pointElement.Rasterize)
            {
                pointElement.Rasterize = false;
            }
            this.Dosomething((Action) delegate()
            {
                graphicsLayer.DeleteElement(pointElement);
            }, true);

            return(true);
        }
Exemple #12
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_gmapControl">地图控件</param>
 /// <param name="_element">图元</param>
 public EditPolygon(GMapControl _gmapControl, IMFElement _element)
 {
     this.gmapControl = _gmapControl;
     this.element     = _element;
     this.polygon     = _element as GMapPolygon;
     editMarkerList   = new List <EditMarker>();
 }
Exemple #13
0
        /// <summary>
        /// 移除线图元
        /// </summary>
        /// <param name="element">要移除的线图元</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public bool RemoveElement(IMFElement element, ILayer layer)
        {
            GlobeGraphicsLayerClass graphicLayer = layer as GlobeGraphicsLayerClass;

            if (graphicLayer == null)
            {
                return(false);
            }

            Line_ArcGlobe line = element as Line_ArcGlobe;

            if (line == null)
            {
                return(false);
            }

            if (line.Rasterize) //判断图元是否栅格化,栅格化之后删不掉图元,所以要先不栅格化
            {
                line.Rasterize = false;
            }
            Dosomething((Action) delegate()
            {
                graphicLayer.DeleteElement(line);//删除线图元
            }, true);

            return(true);
        }
        // 处理预警结果
        public void DealWarnData(RealData data, bool isWarn, List <string> warnNames)
        {
            IMFLayer layer = mapLogic.GetLayer(GetModelLayerName(data.TargetType));

            if (layer == null)
            {
                return;
            }

            IMFElement element = layer.GetElement(data.TargetNum.ToString());

            if (element == null)
            {
                return;
            }

            if (isWarn == false)
            {
                element.Flash(false);
            }
            else
            {
                if (element.IsFlash == false)
                {
                    element.Flash(true, 500);
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// 鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1 && !isControl)
            {
                downPoint = new MapLngLat(e.mapX, e.mapY);
                if (listMapPoints.Count == 0)
                {
                    listMapPoints.Add(downPoint);

                    Kml kmlLine = new Kml();
                    kmlLine.Placemark.Name = "arc_line" + Utils.ElementIndex;

                    KmlLineString line = new KmlLineString();
                    line.PositionList       = listMapPoints;
                    line.Color              = Color.Gray;
                    line.Width              = 2;
                    kmlLine.Placemark.Graph = line;
                    IMFElement element = null;
                    layer.AddElement(kmlLine, out element);
                    lineElement = element as IMFLine;//绘制完成后得到该图元
                    isFinish    = false;
                }
                //若重复点击同一个点则不添加
                else if (listMapPoints.Find(p => p.Lng == downPoint.Lng && p.Lat == downPoint.Lat) == null)
                {
                    listMapPoints.Add(downPoint);
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// 鼠标左键双击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_eventLButtonDbClick(object sender, _DHOSOFTMapControlEvents_eventLButtonDbClickEvent e)
        {
            if (!isControl && listPoints.Count > 2)
            {
                if (!string.IsNullOrEmpty(tempName))
                {
                    mapControl.MgsDelObject(tempName);
                }

                Kml        kml     = new Kml();
                KmlPolygon polygon = new KmlPolygon();
                polygon.PositionList = listPoints;
                polygon.FillColor    = Color.FromArgb(0, Color.White);
                polygon.OutLineColor = Color.Red;
                polygon.OutLineSize  = 3;
                kml.Placemark.Name   = "mgis_polygon" + Utils.ElementIndex;
                kml.Placemark.Graph  = polygon;
                IMFElement element = null;
                layer.AddElement(kml, out element);
                polygonElement = element as IMFPolygon;
                RegistCommondExecutedEvent();
                ReleaseCommond();//修改  陈静
                isFinish = true;
                listPoints.Clear();
            }
        }
Exemple #17
0
        private void SetAreaColorArcMap(string name, Color color)
        {
            IMFLayer layer = mapMapLogic.GetLayer(layerName);

            if (layer == null)
            {
                return;
            }

            IMFElement element = layer.GetElement(name);

            if (element == null)
            {
                return;
            }

            IMFPolygon polygon = element as IMFPolygon;

            if (polygon == null)
            {
                return;
            }

            polygon.SetFillColor(Color.FromArgb(80, color));
        }
Exemple #18
0
 /// <summary>
 /// 鼠标左键双击
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void mapControl_eventLButtonDbClick(object sender, _DHOSOFTMapControlEvents_eventLButtonDbClickEvent e)
 {
     if (!isControl && listPoints.Count >= 2)
     {
         if (!string.IsNullOrEmpty(tempName))
         {
             mapControl.MgsDelObject(tempName);
         }
         //if (listPoints.Count < 2) return;
         Kml           kml  = new Kml();
         KmlLineString line = new KmlLineString();
         line.PositionList   = listPoints;
         line.Color          = System.Drawing.Color.Red;
         line.Width          = 3;
         kml.Placemark.Name  = "mgis_line" + Utils.ElementIndex;
         kml.Placemark.Graph = line;
         IMFElement element = null;
         layer.AddElement(kml, out element);
         lineElement = element as IMFLine;
         RegistCommondExecutedEvent();
         ReleaseCommond();//修改  陈静
         listPoints.Clear();
         isFinish = true;
     }
 }
Exemple #19
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_mapControl">arcgis地图控件</param>
 /// <param name="_element">要编辑的面图元</param>
 public EditPolygon(AxMapControl _mapControl, IMFElement _element)
 {
     element        = _element as IMFPolygon;
     mapControl     = _mapControl;
     markerList     = new List <Model.EditMarker>();
     polygonElement = _element as PolygonElementClass;
     pointList      = new List <Element.Point_ArcMap>();
 }
Exemple #20
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="element">图元</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public bool RemoveElement(IMFElement element, ILayer layer)
        {
            Picture_ArcGlobe   model             = element as Picture_ArcGlobe;
            IGraphicsContainer graphicsContainer = layer as IGraphicsContainer;

            graphicsContainer.DeleteElement(model);
            return(true);
        }
Exemple #21
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_mapControl">arcgis地图控件</param>
 /// <param name="_element">要编辑的线图元</param>
 public EditLine(AxMapControl _mapControl, IMFElement _element)
 {
     element     = _element as IMFLine;
     markerList  = new List <EditMarker>();
     lineElement = _element as LineElementClass;
     mapControl  = _mapControl;
     pointList   = new List <Point_ArcMap>();
 }
Exemple #22
0
 /// <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>();
 }
Exemple #23
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     markerList     = null;
     elementList    = null;
     mapLogic       = null;
     selectedElment = null;
 }
Exemple #24
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_gmapControl">地图控件</param>
 /// <param name="_element">图元</param>
 public EditText(GMapControl _gmapControl, IMFElement _element)
 {
     gmapControl             = _gmapControl;
     marker                  = _element as GMapMarker;
     element                 = _element as IMFText;
     textCtrl                = new TextInput();
     textCtrl.InputFinished += InputFinish;
 }
Exemple #25
0
 /// <summary>
 /// 面点击事件
 /// </summary>
 /// <param name="item"></param>
 /// <param name="e"></param>
 void gmapControl_OnPolygonClick(GMapPolygon item, System.Windows.Forms.MouseEventArgs e)
 {
     selectedElment = mapLogic.GetElement(item.Tag.ToString());
     if (selectedElment == null)
     {
         return;
     }
     selectedElment.HightLight(!selectedElment.IsHightLight);
 }
Exemple #26
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     CommondExecutedEvent = null;
     gmapControl          = null;
     marker      = null;
     isMouseDown = false;
     element     = null;
 }
Exemple #27
0
 /// <summary>
 /// 释放
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     CommondExecutedEvent = null;
     moveObj    = 0;
     element    = null;
     mapControl = null;
     keyDown    = false;
 }
Exemple #28
0
        /// <summary>
        /// 编辑图元
        /// </summary>
        /// <param name="elementName">图元名称</param>
        public void EditElement(string elementName)
        {
            IMFElement element = mapLogic.GetElement(elementName);

            if (element != null)
            {
                EditElement(element);
            }
        }
Exemple #29
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="elementName">图元名称</param>
        /// <returns>true,成功;false,失败</returns>
        /// <param name="element">图元</param>
        public bool RemoveElement(string elementName, ref IMFElement element)
        {
            bool flag = this.RemoveElement(elementName);

            if (flag)
            {
                element = null;
            }
            return(flag);
        }
Exemple #30
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="element">图元</param>
        /// <returns></returns>
        public bool RemoveElement(ref IMFElement element)
        {
            bool flag = RemoveElement(element.ElementName);

            if (flag)
            {
                element = null;
            }
            return(flag);
        }