Ejemplo n.º 1
0
        private void SetAreaColorGlobe(string name, Color color)
        {
            IMFLayer layer = globeMapLogic.GetLayer(layerName);

            if (layer == null)
            {
                return;
            }

            foreach (string polygonName in warnAresDic[name].Polygons)
            {
                var element = layer.GetElement(polygonName);
                if (element == null)
                {
                    continue;
                }

                IMFPolygon polygon = element as IMFPolygon;
                if (polygon == null)
                {
                    continue;
                }
                Color c = Color.FromArgb(80, color.R, color.G, color.B);
                polygon.SetFillColor(c);
            }

            layer.Refresh();
        }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
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);
         }
     }
 }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
0
        private void SetGlobeElementColor(string layerName, string elementName, Color color, bool isSatellite)
        {
            var layer = globeBusiness.mapLogic.GetLayer(layerName);

            if (layer == null)
            {
                return;
            }
            var ele = layer.GetElement(elementName);

            if (ele == null)
            {
                return;
            }

            if (isSatellite)
            {
                I3DModel model = ele as I3DModel;
                if (model == null)
                {
                    return;
                }

                model.SetColor(color);
            }
            else
            {
                IMFPolygon polygon = ele as IMFPolygon;
                if (polygon == null)
                {
                    return;
                }
                polygon.SetFillColor(color);
            }
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
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>();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     listPoints.Clear();
     listPoints     = null;
     tempName       = string.Empty;
     polygonElement = null;
     mapLogic       = null;
     mapControl     = null;
     isFinish       = false;
     isControl      = false;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 鼠标单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1 && !isControl)
            {
                downPoint = new MapLngLat(e.mapX, e.mapY);
                if (listMapPoints.Count == 0)
                {
                    ResultEventArgs(" ");
                    listMapPoints.Add(downPoint);
                    switch (measureType)
                    {
                    case "distance":
                        Kml kmlLine = new Kml();
                        kmlLine.Placemark.Name = "mea_line";

                        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);
                        measureLine = element as IMFLine;    //绘制完成后得到该图元
                        isFinish    = false;
                        break;

                    case "area":
                        Kml kml = new Kml();
                        kml.Placemark.Name = "mea_arcPolygon";
                        Color outlineColor = Color.Blue;
                        Color fillColor    = Color.Black;
                        kml.Placemark.Graph = new KmlPolygon()
                        {
                            FillColor = fillColor, OutLineColor = outlineColor, OutLineSize = 1, PositionList = listMapPoints
                        };
                        IMFElement element1 = null;
                        layer.AddElement(kml, out element1);
                        measurePolygon = element1 as IMFPolygon;
                        isFinish       = false;
                        break;
                    }
                }
                else
                {
                    listMapPoints.Add(downPoint);
                }

                if (segmentLength != 0)
                {
                    //长度
                    toltalLength += segmentLength;
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     CommondExecutedEvent = null;
     gmapControl          = null;
     mapLogic             = null;
     polygonElement       = null;
     listMapPoints        = null;
     layer       = null;
     isMouseDown = false;
     drawn       = false;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     CommondExecutedEvent = null;
     gmapControl          = null;
     mapLogic             = null;
     elementList          = null;
     bIsMultiSelect       = false;
     bIsLeftButtonDown    = false;
     currentPoint         = null;
     pointList            = null;
     polygonElement       = null;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {
            ReleaseCommond();

            CommondExecutedEvent = null;
            mapControl           = null;
            layer          = null;
            polygonElement = null;
            mapLogic       = null;
            pointList      = null;
            isMouseDown    = false;
            isFinish       = false;
            isControl      = false;
        }
Ejemplo n.º 15
0
        /// 重绘区域
        /// </summary>
        /// <param name="name"></param>
        /// <param name="points"></param>
        public void ReDrawArea(string name, List <MapLngLat> points)
        {
            // 先删除之前的面,再添加新的面
            if (!warnAresDic.ContainsKey(name))
            {
                return;
            }

            WarnArea area = warnAresDic[name];

            foreach (string polygonName in area.Polygons)
            {
                IMFLayer layer = globeMapLogic.GetLayer(layerName);
                if (layer == null)
                {
                    return;
                }

                layer.RemoveElement(polygonName);
            }

            bool isWarn      = area.IsWarn;
            bool isImportant = area.IsImportant;

            warnAresDic.Remove(name);

            DrawAreaGlobe(name, points, isWarn, isImportant);

            // arcmap
            IMFLayer layerMap = mapMapLogic.AddLayer(layerName);

            if (layerMap == null)
            {
                return;
            }

            IMFElement ele = layerMap.GetElement(name);

            if (ele == null)
            {
                return;
            }
            IMFPolygon polygon = ele as IMFPolygon;

            if (polygon == null)
            {
                return;
            }
            polygon.UpdatePosition(points);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 鼠标按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gmapControl_MouseDown(object sender, MouseEventArgs e)
        {
            TimeSpan span = DateTime.Now - fistTimer;

            if (span.TotalMilliseconds < 170)
            {
                return;
            }
            fistTimer = DateTime.Now;
            if (e.Clicks == 2 || e.Button != MouseButtons.Left || isMouseDown)
            {
                return;
            }

            var lngLat    = gmapControl.FromLocalToLatLng(e.X, e.Y);
            var maplanLat = new MapLngLat(lngLat.Lng, lngLat.Lat);

            if (listMapPoints.Count == 0)//第一个点  生成多边形
            {
                Kml polygonKml = new Kml();
                polygonKml.Placemark.Name = "draw_polygon" + Utils.ElementIndex;

                listMapPoints.Add(maplanLat);     //添加到集合中
                polygonKml.Placemark.Graph = new KmlPolygon()
                {
                    Description  = "",
                    PositionList = listMapPoints,
                    FillColor    = Color.FromArgb(155, Color.AliceBlue),
                    OutLineColor = Color.FromArgb(155, Color.MidnightBlue)
                };
                IMFElement element = null;
                drawn                  = layer.AddElement(polygonKml, out element); // 添加多边形到地图中
                polygonElement         = element as IMFPolygon;
                gmapControl.MouseMove += gmapControl_MouseMove;
            }
            else
            {
                if (!listMapPoints.Contains(maplanLat))
                {
                    listMapPoints.Add(maplanLat);
                    polygonElement.AddPoint(maplanLat);
                }
            }
        }
Ejemplo n.º 17
0
        private void 添加ToolStripMenuItem2_Click(object sender, System.EventArgs e)
        {
            Kml polygonKml = new Kml();

            polygonKml.Placemark.Name = "polygon";
            List <MapLngLat> pList = new List <MapLngLat>();

            pList.Add(new MapLngLat(102, 45));
            pList.Add(new MapLngLat(97, 16));
            pList.Add(new MapLngLat(89, 62));
            pList.Add(new MapLngLat(79, 63));

            polygonKml.Placemark.Graph = new KmlPolygon()
            {
                Description = "", PositionList = pList,
            };                                                       //position
            mapLogic.GetLayer(drawLayerName).AddElement(polygonKml); //添加多边形到地图中
            polygonElement = mapLogic.GetLayer(drawLayerName).GetElement("polygon") as IMFPolygon;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 鼠标单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gmapControl_MouseDown(object sender, MouseEventArgs e)
        {
            TimeSpan span = DateTime.Now - fistTimer;

            if (span.TotalMilliseconds < 170)
            {
                return;
            }
            fistTimer = DateTime.Now;
            if (e.Clicks == 2 || e.Button != MouseButtons.Left)
            {
                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 = "draw_rectangle" + Utils.ElementIndex;

            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  = "手动绘制矩形",
                PositionList = pList,
                FillColor    = Color.FromArgb(155, Color.AliceBlue),
                OutLineColor = Color.FromArgb(155, Color.MidnightBlue)
            };
            IMFElement element = null;

            drawn          = layer.AddElement(polygonKml, out element);
            rectangElement = element as IMFPolygon;

            gmapControl.MouseMove += gmapControl_MouseMove;
            gmapControl.MouseUp   += gmapControl_MouseUp;
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     mapControl = null;
     mapLogic   = null;
     if (measureTool != null)
     {
         measureTool.Dispose();
     }
     downPoint            = null;
     listMapPoints        = null;
     toltalLength         = 0;
     segmentLength        = 0;
     measureArea          = 0;
     measureLine          = null;
     measurePolygon       = null;
     isFinish             = false;
     isControl            = false;
     measureType          = string.Empty;
     CommondExecutedEvent = null;
 }
Ejemplo n.º 20
0
        // 绘图完成事件
        private void Tool_CommondExecutedEvent(object sender, MapFrame.Core.Model.MessageEventArgs e)
        {
            this.Visible = true;

            var tool = mapLogic.GetToolBox();

            if (tool == null)
            {
                return;
            }

            tool.CommondExecutedEvent -= Tool_CommondExecutedEvent;
            tool.ReleaseTool();

            IMFPolygon polygon = e.Data as IMFPolygon;

            if (polygon == null)
            {
                return;
            }

            List <MapLngLat> points = polygon.GetLngLat();

            if (points == null || points.Count <= 0)
            {
                return;
            }

            txtAreaName.Text = polygon.ElementName;
            var layer = mapLogic.GetLayer(polygon.BelongLayer.LayerName);

            layer.RemoveElement(polygon);

            bool isWarn      = cmbIsWarningArea.SelectedIndex == 0 ? true : false;
            bool isImportant = cmbImportantArea.SelectedIndex == 0 ? true : false;

            wanrMgr.DrawArea(txtAreaName.Text, points, isWarn, isImportant);

            ShowInfo(txtAreaName.Text);
        }
Ejemplo n.º 21
0
        // 更新波束位置
        private void UpdateBeamElement(Beam beam, Model3D model)
        {
            var layer = mapLogic.GetLayer(beam.BeamLayerName);

            if (layer == null)
            {
                return;
            }

            string           elementName      = beam.BeamName;
            List <MapLngLat> pointListPolygon = new List <MapLngLat>();
            List <MapLngLat> pointListCover   = new List <MapLngLat>();

            pointListPolygon.Add(model.Coordinate);
            //pointListCover.Add(new MapLngLat(beam.CenterPoint.Lng, beam.CenterPoint.Lat, 100000));

            for (double tempAngle = -180; tempAngle <= 180; tempAngle = tempAngle + beam.StepValue)
            {
                var p = Utils.GetPointByDistanceAndAngle(beam.Radius, beam.CenterPoint, tempAngle);
                if (p != null)
                {
                    pointListPolygon.Add(p);
                    pointListCover.Add(new MapLngLat(p.Lng, p.Lat, 100000));
                }
            }

            var coverLayer = mapLogic.AddLayer(coverLayerName);

            if (coverLayer != null)
            {
                // 线
                IMFElement eleLine = coverLayer.GetElement(elementName + "cover_line");
                if (eleLine != null)
                {
                    IMFLine line = eleLine as IMFLine;
                    if (line != null)
                    {
                        line.UpdatePosition(pointListCover);
                    }
                }

                // 更新覆盖图元
                IMFElement elePolygon = coverLayer.GetElement(elementName + "cover");
                if (elePolygon != null)
                {
                    IMFPolygon polygonEle = elePolygon as IMFPolygon;
                    if (polygonEle != null)
                    {
                        polygonEle.UpdatePosition(pointListCover);    // 更新覆盖图元位置
                    }
                }
            }

            // 更新波束图元
            IMFElement element = layer.GetElement(elementName);

            if (element == null)
            {
                return;
            }
            IMFPolygon polygonElement = element as IMFPolygon;

            if (polygonElement == null)
            {
                return;
            }
            polygonElement.UpdatePosition(pointListPolygon);    // 更新波束位置

            layer.Refresh();
        }
Ejemplo n.º 22
0
        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;
            }
        }