Ejemplo n.º 1
0
        public override void Draw(PaintEventArgs e, WEStyle style, string str)
        {
            Graphics g = e.Graphics;

            foreach (var i in _Polylines)
            {
                //foreach(var poi in ((WEPolyline)i).Points)
                //g.FillRectangle(new SolidBrush(style.FromColor), WEMapTools.FromMapPoint(poi).X - 2, WEMapTools.FromMapPoint(poi).Y - 2, 4, 4);
                Pen penn = new Pen(new SolidBrush(style.FromColor), (float)style.BoundaryWidth);
                switch (style.SymbolStyle)
                {
                case 0:
                    penn.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    break;

                case 1:
                    penn.DashStyle   = System.Drawing.Drawing2D.DashStyle.Custom;
                    penn.DashPattern = new float[] { 5, 5 };
                    break;
                }
                for (int j = 0; j < ((WEPolyline)i).Points.Length - 1; j++)
                {
                    g.DrawLine(penn, WEMapTools.FromMapPoint(((WEPolyline)i).Points[j]), WEMapTools.FromMapPoint(((WEPolyline)i).Points[j + 1]));
                }
            }
            //g.DrawString(str, new Font("微软雅黑", 8), new SolidBrush(Color.Black), WEMapTools.FromMapPoint(new WEPoint(MBR.MinX + MBR.Width / 2, MBR.MinY + MBR.Height /2)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 求线段长度的中点
        /// </summary>
        /// <returns></returns>
        public override WEPoint[] getCenterPoint()
        {
            WEPoint center = new WEPoint();
            double  length = 0;

            for (int i = 0; i < _Points.Count - 1; i++)      //获取polyline全长
            {
                length += WEMapTools.GetDistance(_Points[i], _Points[i + 1]);
            }
            double calLength = 0;

            for (int i = 0; i < _Points.Count - 1; i++)
            {
                calLength += WEMapTools.GetDistance(_Points[i], _Points[i + 1]);
                if (calLength >= length / 2)     //长度中点在当前段
                {
                    double thisLength = WEMapTools.GetDistance(_Points[i], _Points[i + 1]);
                    double diffLength = calLength - thisLength;
                    center.X = (_Points[i + 1].X - _Points[i].X) * diffLength / thisLength + _Points[i].X;
                    center.Y = (_Points[i + 1].Y - _Points[i].Y) * diffLength / thisLength + _Points[i].Y;
                    break;
                }
            }
            return(new WEPoint[1] {
                center
            });
        }
Ejemplo n.º 3
0
        private void finishPart()
        {
            if (CurrentEdit < 0 || CurrentEdit > AllLayer.Count())
            {
                return;
            }
            List <WEPoint> tem = new List <WEPoint>();

            if (NewPoints.Count() != 0)
            {
                switch (AllLayer[CurrentEdit].FeatureType)
                {
                case FeatureType.WEMultiPoint:
                case FeatureType.WEEntityPoint:
                    break;

                case FeatureType.WEEntityPolyline:
                case FeatureType.WEMultiPolyline:
                    WEMultiPolyline temm  = (WEMultiPolyline)(EditFeature.Geometries);
                    WEPolyline      temmm = (WEPolyline)temm.Polylines[temm.Polylines.Count() - 1];
                    //tem.AddRange(temmm.Points);
                    foreach (var i in NewPoints)
                    {
                        tem.Add(WEMapTools.ToMapPoint(i));
                    }
                    temmm.Points = (WEPoint[])tem.ToArray();
                    temm.DeletePolyline(temm.Polylines.Count() - 1);
                    temm.Add(temmm);
                    temm.Add(new WEPolyline());
                    EditFeature.Geometries = temm;
                    NewPoints.Clear();

                    break;

                case FeatureType.WEEntityPolygon:
                case FeatureType.WEMultiPolygon:
                    WEMultiPolygon temm3  = (WEMultiPolygon)(EditFeature.Geometries);
                    WEPolygon      temmm3 = (WEPolygon)temm3.Polygons[temm3.Polygons.Count() - 1];
                    //tem.AddRange(temmm3.Points);
                    foreach (var i in NewPoints)
                    {
                        tem.Add(WEMapTools.ToMapPoint(i));
                    }
                    temmm3.Points = (WEPoint[])tem.ToArray();
                    temm3.DeletePolygon(temm3.Polygons.Count() - 1);
                    temm3.Add(temmm3);
                    temm3.Add(new WEPolygon());
                    EditFeature.Geometries = temm3;
                    NewPoints.Clear();
                    break;

                default:
                    throw new Exception("不能识别的图层类型");
                }
            }
            else
            {
                System.Media.SystemSounds.Beep.Play();
            }
        }
Ejemplo n.º 4
0
        public override void Draw(PaintEventArgs e, WEStyle style, string str)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            PointF tem;

            foreach (var i in _Points)
            {
                switch (style.SymbolStyle)
                {
                case 1:
                    g.DrawEllipse(new Pen(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 2, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 2, (float)style.Size, (float)style.Size);
                    break;

                case 2:
                    g.FillEllipse(new SolidBrush(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 2, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 2, (float)style.Size, (float)style.Size);
                    break;

                case 3:
                    g.DrawRectangle(new Pen(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 2, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 2, (float)style.Size, (float)style.Size);
                    break;

                case 4:
                    g.FillRectangle(new SolidBrush(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 2, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 2, (float)style.Size, (float)style.Size);
                    break;

                case 5:
                    tem = WEMapTools.FromMapPoint(i);
                    g.DrawLines(new Pen(style.FromColor), new PointF[4] {
                        new PointF(tem.X, tem.Y - (float)style.Size * 2 / 3),
                        new PointF(tem.X - (float)style.Size / 2, tem.Y + (float)style.Size / 3),
                        new PointF(tem.X + (float)style.Size / 3, tem.Y + (float)style.Size / 3),
                        new PointF(tem.X, tem.Y - (float)style.Size * 2 / 3),
                    });
                    break;

                case 6:
                    tem = WEMapTools.FromMapPoint(i);
                    g.FillPolygon(new SolidBrush(style.FromColor), new PointF[4] {
                        new PointF(tem.X, tem.Y - (float)style.Size * 2 / 3),
                        new PointF(tem.X - (float)style.Size / 2, tem.Y + (float)style.Size / 3),
                        new PointF(tem.X + (float)style.Size / 3, tem.Y + (float)style.Size / 3),
                        new PointF(tem.X, tem.Y - (float)style.Size * 2 / 3),
                    });
                    break;

                case 7:
                    g.DrawEllipse(new Pen(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 2, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 2, (float)style.Size, (float)style.Size);
                    g.FillRectangle(new SolidBrush(style.FromColor), WEMapTools.FromMapPoint(i).X - 0.5f, WEMapTools.FromMapPoint(i).Y - 0.5f, 1, 1);
                    break;

                case 8:
                    g.DrawEllipse(new Pen(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 2, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 2, (float)style.Size, (float)style.Size);
                    g.DrawEllipse(new Pen(style.FromColor), WEMapTools.FromMapPoint(i).X - (float)style.Size / 3, WEMapTools.FromMapPoint(i).Y - (float)style.Size / 3, (float)style.Size / 1.5f, (float)style.Size / 1.5f);
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据提供的中心和缩放级别进行缩放
        /// </summary>
        /// <param name="center">缩放的屏幕中心</param>
        /// <param name="ratio">缩放的比例,大于 1 放大,小于 1 缩小</param>
        public void ZoomByCenter(PointF center, double ratio = 1.2)
        {
            PointF poimin = new PointF(center.X * (float)(ratio - 1), center.Y * (float)(ratio - 1));                                                                                                               // 0,0
            PointF poimax = new PointF(WEMapTools.DisplayWidth - (WEMapTools.DisplayWidth - center.X) * (float)(ratio - 1), WEMapTools.DisplayHeight - (WEMapTools.DisplayHeight - center.Y) * (float)(ratio - 1)); // width, height
            //PointF poimin = new PointF(center.X * (float)(ratio - 1), center.Y * (float)(ratio - 1));// 0,0
            //PointF poimax = new PointF(Width - center.X * (float)(ratio - 1), Height - center.Y * (float)(ratio - 1));// width, height
            WEPoint p1 = WEMapTools.ToMapPoint(poimin), p2 = WEMapTools.ToMapPoint(poimax);

            ZoomByMBR(new WERectangle(p1.X, p2.X, p2.Y, p1.Y));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 绘制注记
        /// </summary>
        /// <param name="e"></param>
        public void DrawLabel(PaintEventArgs e)
        {
            Graphics g     = e.Graphics;
            string   field = _Label.Text;

            for (int i = 0; i < _Features.Count; i++)      //对图层中每一个要素绘制注记
            {
                string text     = Data.Rows[i][field].ToString();
                PointF location = WEMapTools.FromMapPoint(_Features[i].Geometries.getCenterPoint()[0]);
                if (_FeatureType == FeatureType.WEEntityPoint || _FeatureType == FeatureType.WEPoint)
                {
                    location.Y -= Label.Font.Size;  //点要素,将注记向下移半个字体大小
                    location.X -= text.Length * Label.Font.Size / 2;
                }
                g.DrawString(text, Label.Font, new SolidBrush(Label.Color), location.X, location.Y);
            }
        }
Ejemplo n.º 7
0
        public override void Draw(PaintEventArgs e, WEStyle style, string str)
        {
            Graphics     g    = e.Graphics;
            GraphicsPath path = new GraphicsPath();

            if (PointCount == 0)
            {
                return;
            }
            foreach (var i in _Polygons)
            {
                if (i.PointCount == 0)
                {
                    continue;
                }
                //foreach (var poi in ((WEPolygon)i).Points)
                //g.FillRectangle(new SolidBrush(style.FromColor), WEMapTools.FromMapPoint(poi).X - 2, WEMapTools.FromMapPoint(poi).Y - 2, 4, 4);

                GraphicsPath  _path = new GraphicsPath();
                List <PointF> temp  = new List <PointF>();
                foreach (var j in ((WEPolygon)i).Points)
                {
                    temp.Add(WEMapTools.FromMapPoint(j));
                }
                temp.Add(temp.First());
                _path.AddLines(temp.ToArray());

                /*
                 * for (int j = 0; j < ((WEPolygon)i).Points.Length - 1; j++)
                 * {
                 *  _path.AddLine(WEMapTools.FromMapPoint(((WEPolygon)i).Points[j]), WEMapTools.FromMapPoint(((WEPolygon)i).Points[j + 1]));
                 *  //g.DrawLine(new Pen(new SolidBrush(Color.Black), 1), WEMapTools.FromMapPoint(((WEPolygon)i).Points[j]), WEMapTools.FromMapPoint(((WEPolygon)i).Points[j + 1]));
                 * }
                 * _path.AddLine(WEMapTools.FromMapPoint(((WEPolygon)i).Points.Last()), WEMapTools.FromMapPoint(((WEPolygon)i).Points.First()));
                 * //g.DrawLine(new Pen(new SolidBrush(Color.Black), 1), WEMapTools.FromMapPoint(((WEPolygon)i).Points.Last()), WEMapTools.FromMapPoint(((WEPolygon)i).Points.First()));
                 */
                path.AddPath(_path, false);
            }
            g.FillPath(new SolidBrush(style.FromColor), path);
            g.DrawPath(new Pen(new SolidBrush(style.BoundaryColor), (float)style.BoundaryWidth), path);
            //g.DrawString(str, new Font("微软雅黑", 8), new SolidBrush(Color.Black), WEMapTools.FromMapPoint(new WEPoint(MBR.MinX + MBR.Width / 2, MBR.MinY + MBR.Height / 2)));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 判断图层里的点是否在矩形盒内并返回部分在矩形盒内的结果
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public override WEFeature[] SelectByBox(WERectangle box)
        {
            List <WEFeature> result = new List <WEFeature> {
            };

            switch (_FeatureType)
            {
            case FeatureType.WEEntityPoint:
                foreach (var i in _Features)
                {
                    if (WEMapTools.IsMultiPointPartiallyWithinBox((WEMultiPoint)i.Geometries, box))
                    {
                        result.Add(i);
                    }
                }
                break;

            //case FeatureType.WEEntityPolyline:
            case FeatureType.WEMultiPolyline:
                foreach (var i in _Features)
                {
                    if (WEMapTools.IsMultiPolylinePartiallyWithinBox((WEMultiPolyline)i.Geometries, box))
                    {
                        result.Add(i);
                    }
                }
                break;

            //case FeatureType.WEEntityPolygon:
            case FeatureType.WEMultiPolygon:
                foreach (var i in _Features)
                {
                    if (WEMapTools.IsMultiPolygonPartiallyWithinBox((WEMultiPolygon)i.Geometries, box))
                    {
                        result.Add(i);
                    }
                }
                break;
            }
            return(result.ToArray());
        }
Ejemplo n.º 9
0
 public override bool Cover(WEPoint poi)
 {
     return(WEMapTools.IsPointOnPoint(poi, this));
 }
Ejemplo n.º 10
0
 public override bool Cover(WEPoint poi)
 {
     return(WEMapTools.IsPointOnMultiPolyline(poi, this));
 }
Ejemplo n.º 11
0
        //鼠标松开
        private void WEMapControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Refresh();
                PointF  poimin, poimax;
                WEPoint p1, p2;
                switch (MapOpStyle)
                {
                case 0:
                    break;

                case 1:
                    if (DisplayScale < 0.0005 && DisplayScale > 0)
                    {
                        return;
                    }
                    if (mStartPoint == e.Location)
                    {
                        ZoomByCenter(e.Location, 1.1);
                    }
                    else
                    {
                        poimin = new PointF(Math.Min(mStartPoint.X, e.Location.X), Math.Min(mStartPoint.Y, e.Location.Y));    // 0,0
                        poimax = new PointF(Math.Max(mStartPoint.X, e.Location.X), Math.Max(mStartPoint.Y, e.Location.Y));
                        p1     = WEMapTools.ToMapPoint(poimin);
                        p2     = WEMapTools.ToMapPoint(poimax);
                        ZoomByMBR(new WERectangle(p1.X, p2.X, p2.Y, p1.Y));
                    }
                    break;

                case 2:
                    if (mStartPoint == e.Location)
                    {
                        ZoomByCenter(e.Location, 1 / 1.1);
                    }
                    else
                    {
                        PointF center = new PointF((mStartPoint.X + e.Location.X) / (float)2.0, (mStartPoint.Y + e.Location.Y) / (float)2.0);
                        poimin = new PointF(Math.Min(mStartPoint.X, e.Location.X), Math.Min(mStartPoint.Y, e.Location.Y));    // 0,0
                        poimax = new PointF(Math.Max(mStartPoint.X, e.Location.X), Math.Max(mStartPoint.Y, e.Location.Y));
                        ZoomByCenter(center, Math.Min((poimax.X - poimin.X) / WEMapTools.DisplayWidth, (poimax.Y - poimin.Y) / WEMapTools.DisplayHeight));
                    }
                    break;

                case 3:
                    break;

                case 4:    //输入多边形
                    break;

                case 5:    //选择要素
                    int flag = -1;
                    if (mStartPoint == e.Location)
                    {
                        p1 = WEMapTools.ToMapPoint(e.Location);
                        for (int i = 0; i < AllLayer.Count; i++)
                        {
                            var layer = AllLayer[i];
                            if (!layer.Visible)
                            {
                                continue;
                            }
                            if (flag != -1)
                            {
                                break;
                            }
                            foreach (WEFeature fea in layer.Features)
                            {
                                if (fea.Geometries.Cover(p1))
                                {
                                    _SelectedGeometries.Add(fea);
                                    flag = i;
                                    break;
                                }
                            }
                        }
                        Refresh();
                    }
                    else
                    {
                        poimin = new PointF(Math.Min(mStartPoint.X, e.Location.X), Math.Min(mStartPoint.Y, e.Location.Y));    // 0,0
                        poimax = new PointF(Math.Max(mStartPoint.X, e.Location.X), Math.Max(mStartPoint.Y, e.Location.Y));
                        p1     = WEMapTools.ToMapPoint(poimin);
                        p2     = WEMapTools.ToMapPoint(poimax);
                        for (int i = 0; i < AllLayer.Count; i++)
                        {
                            var layer = AllLayer[i];
                            if (!layer.Visible)
                            {
                                continue;
                            }
                            _SelectedGeometries.AddRange(layer.SelectByBox(new WERectangle(p1.X, p2.X, p2.Y, p1.Y)).ToArray());
                        }

                        Refresh();

                        //if (SelectingFinished != null)
                        //SelectingFinished(this);
                    }
                    List <int> ids = new List <int> {
                    };
                    foreach (var i in _SelectedGeometries)
                    {
                        ids.Add(i.ID);
                    }
                    if (SelectingFinished != null)
                    {
                        if (_SelectedGeometries.Count != 0)
                        {
                            EditFeature = _SelectedGeometries[0];
                            SelectingFinished(this, ids.ToArray(), flag, _SelectedGeometries[0]);
                        }
                        else
                        {
                            SelectingFinished(this, ids.ToArray(), flag, null);
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        //鼠标移动
        private void WEMapControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (WEMouseMove != null)
            {
                WEMouseMove(this, e.Location);
            }
            switch (MapOpStyle)
            {
            case 0:
                break;

            case 1:                 //放大
                if (e.Button == MouseButtons.Left)
                {
                    Refresh();
                    Graphics g       = Graphics.FromHwnd(this.Handle);
                    Pen      sBoxPen = new Pen(mcSelectingBoxColor, mcSelectingBoxWidth);
                    float    sMinX   = Math.Min(mStartPoint.X, e.Location.X);
                    float    sMinY   = Math.Min(mStartPoint.Y, e.Location.Y);
                    float    sMaxX   = Math.Max(mStartPoint.X, e.Location.X);
                    float    sMaxY   = Math.Max(mStartPoint.Y, e.Location.Y);
                    g.DrawRectangle(sBoxPen, sMinX, sMinY, sMaxX - sMinX, sMaxY - sMinY);
                    g.Dispose();
                }
                break;

            case 2:                 //缩小
                if (e.Button == MouseButtons.Left)
                {
                    Refresh();
                    Graphics g       = Graphics.FromHwnd(this.Handle);
                    Pen      sBoxPen = new Pen(mcSelectingBoxColor, mcSelectingBoxWidth);
                    float    sMinX   = Math.Min(mStartPoint.X, e.Location.X);
                    float    sMinY   = Math.Min(mStartPoint.Y, e.Location.Y);
                    float    sMaxX   = Math.Max(mStartPoint.X, e.Location.X);
                    float    sMaxY   = Math.Max(mStartPoint.Y, e.Location.Y);
                    g.DrawRectangle(sBoxPen, sMinX, sMinY, sMaxX - sMinX, sMaxY - sMinY);
                    g.Dispose();
                }
                break;

            case 3:                 //漫游
                if (e.Button == MouseButtons.Left)
                {
                    //PointF sPreMouseLocation = new PointF(mStartPoint.X, mStartPoint.Y);
                    //WEPoint sPrePoint = WEMapTools.ToMapPoint(sPreMouseLocation);
                    WEPoint sPrePoint = WEMapTools.ToMapPoint(mStartPoint);
                    //PointF sCurMouseLocation = new PointF(e.Location.X, e.Location.Y);
                    //WEPoint sCurPoint = WEMapTools.ToMapPoint(sCurMouseLocation);
                    WEPoint sCurPoint = WEMapTools.ToMapPoint(e.Location);
                    WEPoint offset    = WEMapTools.ToMapPoint(new PointF(e.Location.X - mStartPoint.X, e.Location.Y - mStartPoint.Y));
                    //修改offset
                    double      mOffsetX = sPrePoint.X - sCurPoint.X;
                    double      mOffsetY = sPrePoint.Y - sCurPoint.Y;
                    WERectangle newRect  = new WERectangle(WEMapTools.DisplayMBR.MinX + mOffsetX, WEMapTools.DisplayMBR.MaxX + mOffsetX,
                                                           WEMapTools.DisplayMBR.MinY + mOffsetY, WEMapTools.DisplayMBR.MaxY + mOffsetY);
                    WEMapTools.DisplayMBR = newRect;
                    ZoomByMBR(WEMapTools.DisplayMBR);
                    mStartPoint = e.Location;

                    /*
                     * //修改offset
                     * mOffsetX = (mStartPoint.X - e.Location.X) * WEMapTools.DisplayMBR.Width / WEMapTools.DisplayWidth;
                     * mOffsetY = (e.Location.Y - mStartPoint.Y) * WEMapTools.DisplayMBR.Height / WEMapTools.DisplayHeight;
                     * newRect = new WERectangle(WEMapTools.DisplayMBR.MinX + mOffsetX, WEMapTools.DisplayMBR.MaxX + mOffsetX,
                     *  WEMapTools.DisplayMBR.MinY + mOffsetY, WEMapTools.DisplayMBR.MaxY + mOffsetY);
                     * WEMapTools.DisplayMBR = newRect;
                     * ZoomByMBR(WEMapTools.DisplayMBR);
                     * mStartPoint.X = e.Location.X;
                     * mStartPoint.Y = e.Location.Y;
                     */
                }
                break;

            case 4:
                mStartPoint = e.Location;
                List <WEPoint> tem = new List <WEPoint>();
                if (CurrentEdit < 0 || CurrentEdit > AllLayer.Count())
                {
                    break;
                }
                if (NodeEdit == 0)
                {
                    switch (AllLayer[CurrentEdit].FeatureType)
                    {
                    case FeatureType.WEMultiPoint:
                    case FeatureType.WEEntityPoint:
                        if (NewPoints.Count() != 0)
                        {
                            NewPoints[0]           = e.Location;
                            EditFeature.Geometries = new WEMultiPoint(new WEPoint[1] {
                                WEMapTools.ToMapPoint(NewPoints[0])
                            });
                        }
                        else
                        {
                            NewPoints.Add(e.Location);
                        }
                        //NewPoints.Clear();
                        //EditFeature = AllLayer[CurrentEdit].Features.Last();
                        //AllLayer[CurrentEdit].Features[AllLayer[CurrentEdit].Features.Count() - 1].Geometries = new WEMultiPoint(new WEGeometry[1] {  });
                        break;

                    case FeatureType.WEEntityPolyline:
                    case FeatureType.WEMultiPolyline:
                        NewPoints.Add(e.Location);

                        WEMultiPolyline temm  = (WEMultiPolyline)(EditFeature.Geometries);
                        WEPolyline      temmm = (WEPolyline)temm.Polylines[temm.Polylines.Count() - 1];
                        //tem.AddRange(temmm.Points);
                        foreach (var i in NewPoints)
                        {
                            tem.Add(WEMapTools.ToMapPoint(i));
                        }
                        temmm.Points = (WEPoint[])tem.ToArray();
                        temm.DeletePolyline(temm.Polylines.Count() - 1);
                        temm.Add(temmm);
                        EditFeature.Geometries = temm;

                        NewPoints.RemoveAt(NewPoints.Count - 1);

                        break;

                    case FeatureType.WEEntityPolygon:
                    case FeatureType.WEMultiPolygon:
                        NewPoints.Add(e.Location);

                        WEMultiPolygon temm3  = (WEMultiPolygon)(EditFeature.Geometries);
                        WEPolygon      temmm3 = (WEPolygon)temm3.Polygons[temm3.Polygons.Count() - 1];
                        //tem.AddRange(temmm3.Points);
                        foreach (var i in NewPoints)
                        {
                            tem.Add(WEMapTools.ToMapPoint(i));
                        }
                        temmm3.Points = (WEPoint[])tem.ToArray();
                        temm3.DeletePolygon(temm3.Polygons.Count() - 1);
                        temm3.Add(temmm3);
                        EditFeature.Geometries = temm3;

                        NewPoints.RemoveAt(NewPoints.Count - 1);

                        break;
                    }
                    Refresh();
                }
                else if (EditFeature.Geometries.PointCount != 0)
                {
                    CursorMap = WEMapTools.ToMapPoint(e.Location);
                    switch (EditFeature.FeatureType)
                    {
                    case FeatureType.WEMultiPoint:
                    case FeatureType.WEEntityPoint:
                        isGravitationCaptured = -1;
                        for (int i = 0; i < EditFeature.Geometries.PointCount; i++)
                        {
                            WEPoint poi = (WEPoint)((WEMultiPoint)EditFeature.Geometries).Points[i];
                            if (WEMapTools.IsPointOnPoint(CursorMap, poi))
                            {
                                isGravitationCaptured = i;
                                break;
                            }
                        }
                        break;

                    case FeatureType.WEEntityPolyline:
                    case FeatureType.WEMultiPolyline:
                        isGravitationCaptured = -1;
                        for (int i = 0; i < EditFeature.Geometries.PointCount; i++)
                        {
                            WEPolyline polyline = (WEPolyline)((WEMultiPolyline)EditFeature.Geometries).Polylines[i];
                            for (int j = 0; j < polyline.PointCount; j++)
                            {
                                if (WEMapTools.IsPointOnPoint(CursorMap, polyline.Points[j]))
                                {
                                    isGravitationCaptured = j;
                                    break;
                                }
                            }
                            if (isGravitationCaptured != -1)
                            {
                                helpGravitationCaptured = i;
                                break;
                            }
                            if (polyline.PointCount == 1)
                            {
                                continue;
                            }
                            for (int j = 1; j < polyline.PointCount; j++)
                            {
                                if (WEMapTools.IsPointOnPolyline(CursorMap, new WEPolyline(new WEPoint[2] {
                                    polyline.Points[j], polyline.Points[j - 1]
                                })))
                                {
                                    ;
                                }
                                {
                                    isGravitationCaptured = j;
                                    break;
                                }
                            }
                            if (isGravitationCaptured != -1)
                            {
                                helpGravitationCaptured = -i;
                                break;
                            }
                        }
                        break;

                    case FeatureType.WEEntityPolygon:
                    case FeatureType.WEMultiPolygon:
                        isGravitationCaptured = -1;
                        for (int i = 0; i < EditFeature.Geometries.PointCount; i++)
                        {
                            WEPolygon polygon = (WEPolygon)((WEMultiPolyline)EditFeature.Geometries).Polylines[i];
                            for (int j = 0; j < polygon.PointCount; j++)
                            {
                                if (WEMapTools.IsPointOnPoint(CursorMap, polygon.Points[j]))
                                {
                                    isGravitationCaptured = j;
                                    break;
                                }
                            }
                            if (isGravitationCaptured != -1)
                            {
                                helpGravitationCaptured = i;
                                break;
                            }
                            if (polygon.PointCount == 1)
                            {
                                continue;
                            }
                            for (int j = 1; j < polygon.PointCount; j++)
                            {
                                if (WEMapTools.IsPointOnPolyline(CursorMap, new WEPolyline(new WEPoint[2] {
                                    polygon.Points[j], polygon.Points[j - 1]
                                })))
                                {
                                    ;
                                }
                                {
                                    isGravitationCaptured = j;
                                    break;
                                }
                            }
                            if (WEMapTools.IsPointOnPolyline(CursorMap, new WEPolyline(new WEPoint[2] {
                                polygon.Points.Last(), polygon.Points.First()
                            })))
                            {
                                ;
                            }
                            isGravitationCaptured = polygon.PointCount;
                            if (isGravitationCaptured != -1)
                            {
                                helpGravitationCaptured = -i;
                                break;
                            }
                        }
                        break;

                    default:
                        isGravitationCaptured = -1;
                        break;
                    }
                    if (isGravitationCaptured != -1)
                    {
                        Cursor = Cursors.SizeAll;
                        using (Graphics g = Graphics.FromHwnd(this.Handle))
                        {
                            g.FillRectangle(new SolidBrush(Color.Black), 0, 0, 100, 100);
                        }
                    }
                    else
                    {
                        Cursor = Cursors.Cross;
                    }
                }
                if (isGravitationCaptured != -1)
                {
                }

                break;

            case 5:                 //选择要素
                if (e.Button == MouseButtons.Left)
                {
                    Refresh();
                    Graphics g       = Graphics.FromHwnd(this.Handle);
                    Pen      sBoxPen = new Pen(mcSelectingBoxColor, mcSelectingBoxWidth);
                    float    sMinX   = Math.Min(mStartPoint.X, e.Location.X);
                    float    sMinY   = Math.Min(mStartPoint.Y, e.Location.Y);
                    float    sMaxX   = Math.Max(mStartPoint.X, e.Location.X);
                    float    sMaxY   = Math.Max(mStartPoint.Y, e.Location.Y);
                    g.DrawRectangle(sBoxPen, sMinX, sMinY, sMaxX - sMinX, sMaxY - sMinY);
                    g.Dispose();
                }
                break;

            default:
                mStartPoint = e.Location;
                break;
            }
        }