Exemplo 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)));
        }
Exemplo n.º 2
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;
                }
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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)));
        }