Exemple #1
0
 /// <summary>
 /// 鼠标双击停止绘制
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gmapControl_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && polygonElement != null)
     {
         polygonElement.UpdatePosition(listMapPoints);//更新一次
         layer.Refresh();
         gmapControl.MouseMove -= gmapControl_MouseMove;
         drawn = false;
         listMapPoints.Clear();
         RegistCommondExcuteEvent();
         ReleaseCommond();//修改  陈静
     }
 }
Exemple #2
0
        // 鼠标移动事件,主要完成矩形绘制
        private void gmapControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (bIsLeftButtonDown == false || bIsMultiSelect == false)
            {
                return;                                                          // 如果鼠标左键和Ctrl没有按下,则不执行操作
            }
            if (currentPoint == null)
            {
                return;
            }

            PointLatLng point = gmapControl.FromLocalToLatLng(e.X, e.Y);
            //右上角
            MapLngLat p1 = new MapLngLat(point.Lng, currentPoint.Lat);
            //右下角
            MapLngLat p2 = new MapLngLat(point.Lng, point.Lat);
            //左下角
            MapLngLat p3 = new MapLngLat(currentPoint.Lng, point.Lat);

            pointList[1] = p1;
            pointList[2] = p2;
            pointList[3] = p3;
            //修改其他三个点的位置

            if (polygonElement != null)
            {
                polygonElement.UpdatePosition(pointList);
            }
        }
Exemple #3
0
        /// <summary>
        /// 鼠标移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {
            if (listMapPoints.Count != 0)
            {
                MapLngLat moveLnglat = new MapLngLat(e.mapX, e.mapY);
                if (!isControl)//若没有按下空格
                {
                    listMapPoints.Add(moveLnglat);

                    switch (measureType)
                    {
                    case "distance":
                        measureLine.UpdatePosition(listMapPoints);
                        segmentLength = MapFrame.Core.Common.Utils.GetDistance(downPoint, moveLnglat);
                        toltalLength += segmentLength;
                        ResultEventArgs(string.Format("当前线段长度为:{0} 千米 \n总线段长度为:{1}千米", segmentLength, toltalLength));
                        toltalLength -= segmentLength;
                        break;

                    case "area":

                        measurePolygon.UpdatePosition(listMapPoints);
                        IPolygon             polygon     = new PolygonClass();
                        IGeometry            geometry    = null;
                        ITopologicalOperator topo        = null;
                        IPointCollection     pointCollec = new PolygonClass();
                        for (int i = 0; i < listMapPoints.Count; i++)
                        {
                            pointCollec.AddPoint(new PointClass()
                            {
                                X = listMapPoints[i].Lng, Y = listMapPoints[i].Lat
                            });
                        }
                        polygon = pointCollec as IPolygon;
                        if (polygon != null)
                        {
                            polygon.Close();
                            geometry = polygon as IGeometry;
                            topo     = geometry as ITopologicalOperator;
                            topo.Simplify();
                            geometry.Project(mapControl.Map.SpatialReference);
                            IArea area = geometry as IArea;

                            if (area != null)
                            {
                                measureArea = area.Area;
                                ResultEventArgs(string.Format("面积为:{0} 万平方千米", measureArea));
                                polygon = null;
                            }
                        }
                        break;
                    }
                    listMapPoints.Remove(moveLnglat);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// 鼠标移动事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
 {
     if (isMouseDown && !isControl)
     {
         MapLngLat lnglat1 = new MapLngLat(pointList[0].Lng, e.mapY);
         MapLngLat lnglat2 = new MapLngLat(e.mapX, e.mapY);
         MapLngLat lnglat3 = new MapLngLat(e.mapX, pointList[0].Lat);
         pointList[1] = lnglat1;
         pointList[2] = lnglat2;
         pointList[3] = lnglat3;
         polygonElement.UpdatePosition(pointList);
     }
 }
Exemple #5
0
 /// <summary>
 /// 鼠标移动实时生成
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
 {
     if (listMapPoints.Count != 0 && !isControl)
     {
         MapLngLat moveLngLat = new MapLngLat()
         {
             Lng = e.mapX, Lat = e.mapY
         };
         listMapPoints.Add(moveLngLat);
         polygonElement.UpdatePosition(listMapPoints);
         listMapPoints.Remove(moveLngLat);
     }
 }
Exemple #6
0
        /// <summary>
        /// 鼠标移动事件  拉大矩形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gmapControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (!drawn)
            {
                return;
            }
            PointLatLng point = gmapControl.FromLocalToLatLng(e.X, e.Y);
            //右上角
            MapLngLat p1 = new MapLngLat(0, 0);
            //右下角
            MapLngLat p2 = new MapLngLat(0, 0);
            //左下角
            MapLngLat p3 = new MapLngLat(0, 0);

            if (bIsCtrlDown) //画正方形
            {
                double x = point.Lng - currentPoint.Lng;
                double y = point.Lat - currentPoint.Lat;
                if (x > y)
                {
                    pointList[1].Lng = currentPoint.Lng + y;
                    pointList[1].Lat = currentPoint.Lat;
                    pointList[2].Lng = currentPoint.Lng + y;
                    pointList[2].Lat = point.Lat;
                    pointList[3].Lng = currentPoint.Lng;
                    pointList[3].Lat = currentPoint.Lat + y;
                }
                else
                {
                    pointList[1].Lng = currentPoint.Lng + x;
                    pointList[1].Lat = currentPoint.Lat;
                    pointList[2].Lng = point.Lng;
                    pointList[2].Lat = currentPoint.Lat + x;
                    pointList[3].Lng = currentPoint.Lng;
                    pointList[3].Lat = pointList[1].Lat;
                }
            }
            else      //画矩形
            {
                pointList[1].Lng = point.Lng;
                pointList[1].Lat = currentPoint.Lat;
                pointList[2].Lng = point.Lng;
                pointList[2].Lat = point.Lat;
                pointList[3].Lng = currentPoint.Lng;
                pointList[3].Lat = point.Lat;
            }

            //修改其他三个点的位置
            rectangElement.UpdatePosition(pointList);
        }
Exemple #7
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);
        }
Exemple #8
0
        private void 更新位置ToolStripMenuItem2_Click(object sender, System.EventArgs e)
        {
            if (polygonElement == null)
            {
                return;
            }
            MapLngLat        m1      = new MapLngLat(111, 56);
            MapLngLat        m2      = new MapLngLat(89, 76);
            MapLngLat        m3      = new MapLngLat(92, 66);
            MapLngLat        m4      = new MapLngLat(100, 86);
            List <MapLngLat> listMap = new List <MapLngLat>();

            listMap.Add(m1);
            listMap.Add(m2);
            listMap.Add(m3);
            listMap.Add(m4);
            polygonElement.UpdatePosition(listMap);
        }
Exemple #9
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();
        }