Пример #1
0
        /// <summary>
        /// 获取图层默认样式
        /// 点图层:颜色-seagreen,边界色-black,边界宽-2;
        /// 线图层:颜色-DarkSlateGray,边界色-DarkSlateGray,线宽-5
        /// 面图层:颜色-从颜色表中随机选取,边界色-black,边界宽-2
        /// </summary>
        /// <param name="mapType"></param>
        /// <returns></returns>
        public static WEStyle GetDefaultRender(FeatureType mapType)
        {
            WEStyle DefaultStyle = new WEStyle();

            DefaultStyle.SymbolMethod = 1;      //默认样式使用唯一值渲染
            if (mapType == FeatureType.WEPoint || mapType == FeatureType.WEMultiPoint || mapType == FeatureType.WEEntityPoint)
            {
                DefaultStyle.BoundaryColor = Color.Black;
                DefaultStyle.FromColor     = Color.SeaGreen;
                DefaultStyle.ToColor       = DefaultStyle.FromColor;
                DefaultStyle.BoundaryWidth = 2;
            }
            if (mapType == FeatureType.WEPolygon || mapType == FeatureType.WEMultiPolygon || mapType == FeatureType.WEEntityPolygon)
            {
                //面的颜色从颜铯表中随机选取
                Random r = new Random();
                DefaultStyle.FromColor     = surfaceColorTable[r.Next(0, surfaceColorTable.Count())];
                DefaultStyle.ToColor       = DefaultStyle.FromColor;
                DefaultStyle.BoundaryColor = Color.Black;
                DefaultStyle.BoundaryWidth = 2;
            }
            if (mapType == FeatureType.WEPolyline || mapType == FeatureType.WEMultiPolyline || mapType == FeatureType.WEEntityPolyline)
            {
                DefaultStyle.BoundaryColor = Color.DarkSlateGray;
                DefaultStyle.FromColor     = DefaultStyle.ToColor = Color.DarkSlateGray;
                DefaultStyle.BoundaryWidth = 5;
            }
            return(DefaultStyle);
        }
Пример #2
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)));
        }
Пример #3
0
        private void Single_Apply_Click(object sender, EventArgs e)
        {
            WEMapObjects.WEStyle newStyle = new WEMapObjects.WEStyle();
            newStyle.SymbolMethod = 1;
            if (_mapType == 1)
            {
                newStyle.SymbolStyle   = Single_symbol.SelectedIndex + 1;           //符号
                newStyle.Size          = Convert.ToDouble(Single_size.Value);       //尺寸
                newStyle.FromColor     = newStyle.ToColor = Single_Color.BackColor; //颜色
                newStyle.BoundaryWidth = Convert.ToDouble(Single_bdrWidth.Value);   //边界宽度
                newStyle.BoundaryColor = Single_bdrColor.BackColor;                 //边界颜色
            }
            if (_mapType == 2)
            {
                newStyle.SymbolStyle = Single_symbol.SelectedIndex;               //符号
                newStyle.Size        = Convert.ToDouble(Single_size.Value);       //尺寸
                newStyle.FromColor   = newStyle.ToColor = Single_Color.BackColor; //颜色
            }
            if (_mapType == 3)
            {
                newStyle.FromColor     = newStyle.ToColor = Single_Color.BackColor; //颜色
                newStyle.BoundaryWidth = Convert.ToDouble(Single_bdrWidth.Value);   //边界宽度
                newStyle.BoundaryColor = Single_bdrColor.BackColor;                 //边界颜色
            }
            newStyle.LabelVisible = checkBox1.Checked;
            //DialogResult = DialogResult.OK;
            SetStyle = newStyle;
            _parentForm.AllLayer[_styleLayerNum].SymbolStyle = SetStyle;
            _parentForm.AllLayer[_styleLayerNum].Label       = SetLabel;
            _parentForm.weMapControl1.AllLayer = _parentForm.AllLayer;
            _parentForm.weMapControl1.Refresh();

            //_parentForm.AllLayer[]
        }
Пример #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;
                }
            }
        }
Пример #5
0
 public WEVectorLayer(int id, string layername, string description, FeatureType type,
                      WEFeature[] geometries, bool visible, bool selectable, WEStyle style)
 {
     _ID          = id;
     _LayerName   = layername;
     _Description = description;
     _FeatureType = type;
     _Features.AddRange(geometries);
     _Visible    = visible;
     _Selectable = selectable;
     _LayerStyle = style;
 }
Пример #6
0
        private void Unique_Apply_Click(object sender, EventArgs e)
        {
            WEMapObjects.WEUniqueValueRender newStyle = new WEMapObjects.WEUniqueValueRender();
            newStyle.SymbolMethod = 2;
            newStyle.Field        = UniqVal_Field.SelectedItem.ToString();
            List <string> UniqVals             = new List <string>();
            List <WEMapObjects.WEStyle> styles = new List <WEMapObjects.WEStyle>();

            if (_mapType == 1)
            {
                newStyle.SymbolStyle   = Single_symbol.SelectedIndex + 1;           //符号
                newStyle.Size          = Convert.ToDouble(Single_size.Value);       //尺寸
                newStyle.FromColor     = newStyle.ToColor = Single_Color.BackColor; //颜色
                newStyle.BoundaryWidth = Convert.ToDouble(Single_bdrWidth.Value);   //边界宽度
                newStyle.BoundaryColor = Single_bdrColor.BackColor;                 //边界颜色
            }
            else if (_mapType == 2)
            {
                newStyle.SymbolStyle = Single_symbol.SelectedIndex;               //符号
                newStyle.Size        = Convert.ToDouble(Single_size.Value);       //尺寸
                newStyle.FromColor   = newStyle.ToColor = Single_Color.BackColor; //颜色
            }
            else if (_mapType == 3)
            {
                newStyle.FromColor     = newStyle.ToColor = Single_Color.BackColor; //颜色
                newStyle.BoundaryWidth = Convert.ToDouble(Single_bdrWidth.Value);   //边界宽度
                newStyle.BoundaryColor = Single_bdrColor.BackColor;                 //边界颜色
            }

            for (int i = 0; i < AttributeTable.RowCount - 1; i++)
            {
                UniqVals.Add(AttributeTable.Rows[i].Cells[1].Value.ToString());
                WEMapObjects.WEStyle s = new WEMapObjects.WEStyle();
                s.FromColor     = s.ToColor = AttributeTable.Rows[i].Cells[0].Style.BackColor; //仅设置了样式的颜色
                s.Size          = newStyle.Size;
                s.SymbolStyle   = newStyle.SymbolStyle;
                s.BoundaryColor = newStyle.BoundaryColor;
                s.BoundaryWidth = newStyle.BoundaryWidth;
                styles.Add(s);
            }
            newStyle.UniqueValue  = UniqVals;
            newStyle.Symbols      = styles;
            newStyle.LabelVisible = checkBox1.Checked;
            //DialogResult = DialogResult.OK;
            SetStyle = newStyle;
            _parentForm.AllLayer[_styleLayerNum].SymbolStyle = SetStyle;
            _parentForm.AllLayer[_styleLayerNum].Label       = SetLabel;
            _parentForm.weMapControl1.AllLayer = _parentForm.AllLayer;
            _parentForm.weMapControl1.Refresh();

            //_parentForm.AllLayer[]
        }
Пример #7
0
 public WERasterLayer(int id, string layername, string description, FeatureType type,
                      List <List <List <double> > > data, bool visible, bool selectable, WEStyle style)
 {
     _ID          = id;
     _LayerName   = layername;
     _Description = description;
     _FeatureType = type;
     _Visible     = visible;
     _Selectable  = selectable;
     _LayerStyle  = style;
     _Data        = data;
     _BandCount   = _Data.Count();
     _Width       = _Data[0][0].Count();
     _Height      = _Data[0].Count();
 }
Пример #8
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)));
        }
Пример #9
0
        public WELayer(string filePath, FeatureType layerType = FeatureType.WENULL)
        {
            string fileType = filePath.Split('.').Last();

            if (fileType == "shp")
            {
                WELayer newLayer = WEIO.ReadLayer(filePath);
                this._ID          = newLayer.ID;
                this._LayerName   = newLayer.LayerName;
                this._FileName    = filePath;
                this._Description = newLayer.Description;
                this._FeatureType = newLayer.FeatureType;
                this._LayerStyle  = newLayer.SymbolStyle;
                this._MBR         = newLayer._MBR;
                this._Visible     = true;
                this._Selectable  = true;
            }
            else if (fileType == "tif")
            {
                ;
            }
        }
Пример #10
0
        /// <summary>
        /// 绘制
        /// </summary>
        /// <param name="e"></param>
        public override void Draw(PaintEventArgs e)
        {
            if (!Visible)
            {
                return;
            }
            //Graphics g = e.Graphics;
            switch (_LayerStyle.SymbolMethod)
            {
            case 1:
                foreach (var i in _ShowFeatures)
                {
                    i.Geometries.Draw(e, _LayerStyle, "");
                }
                break;

            case 2:
                foreach (var i in _ShowFeatures)
                {
                    i.Geometries.Draw(e, ((WEUniqueValueRender)_LayerStyle).Symbols[
                                          ((WEUniqueValueRender)_LayerStyle).UniqueValue.IndexOf(i.Attributes[((WEUniqueValueRender)_LayerStyle).Field].ToString())
                                      ], "");
                }
                break;

            case 3:
                WEClassBreaksRender style = (WEClassBreaksRender)_LayerStyle;
                if (_ShowFeatures.Count == 0)
                {
                    return;
                }
                if (style.Field == "FID")
                {
                    double diff = _Features.Count() * 1.0 / style.BreakCount;
                    for (int i = 0; i < _ShowFeatures.Count; i++)
                    {
                        int   rank      = (int)Math.Ceiling(_ShowFeatures[i].ID / diff + 0.1) - 1;
                        Color FromColor = Color.FromArgb(
                            (int)style.FromColor.R + ((int)style.ToColor.R - (int)style.FromColor.R) / (style.BreakCount - rank),
                            (int)style.FromColor.G + ((int)style.ToColor.G - (int)style.FromColor.G) / (style.BreakCount - rank),
                            (int)style.FromColor.B + ((int)style.ToColor.B - (int)style.FromColor.B) / (style.BreakCount - rank)
                            );

                        WEStyle newSty = new WEStyle(style.SymbolMethod, style.SymbolStyle, style.BoundaryColor,
                                                     FromColor, FromColor, style.Size, style.BoundaryWidth);
                        _Features[i].Geometries.Draw(e, newSty, "");
                    }
                }
                else
                {
                    double min = Convert.ToDouble(_ShowFeatures[0].Attributes[style.Field]), max = Convert.ToDouble(_ShowFeatures[0].Attributes[style.Field]);
                    //double min = (double)_ShowFeatures[0].Attributes[style.Field], max = (double)_ShowFeatures[0].Attributes[style.Field];
                    for (int i = 0; i < _Features.Count(); i++)
                    {
                        double helo = Convert.ToDouble(_Features[i].Attributes[style.Field]);
                        if (helo > max)
                        {
                            max = helo;
                        }
                        if (helo < min)
                        {
                            min = helo;
                        }
                    }
                    double diff = (max - min) / style.BreakCount;
                    foreach (var i in _ShowFeatures)
                    {
                        int   rank      = (int)((Convert.ToDouble(i.Attributes[style.Field]) - min - 0.0000001) / diff);
                        Color FromColor = Color.FromArgb(
                            (int)style.FromColor.R + ((int)style.ToColor.R - (int)style.FromColor.R) / (style.BreakCount - rank),
                            (int)style.FromColor.G + ((int)style.ToColor.G - (int)style.FromColor.G) / (style.BreakCount - rank),
                            (int)style.FromColor.B + ((int)style.ToColor.B - (int)style.FromColor.B) / (style.BreakCount - rank)
                            );

                        WEStyle newSty = new WEStyle(style.SymbolMethod, style.SymbolStyle, style.BoundaryColor,
                                                     FromColor, FromColor, style.Size, style.BoundaryWidth);
                        //_Features[i].Geometries.Draw(e, newSty, "");

                        //WEStyle newSty = style.Symbols[(int)(((double)(i.Attributes[style.Field]) - min - 0.0000001) / diff)];
                        i.Geometries.Draw(e, newSty, "");
                    }
                }
                break;
            }
            if (_LayerStyle.LabelVisible)
            {
                DrawLabel(e);
            }
        }
Пример #11
0
 public virtual void Draw(System.Windows.Forms.PaintEventArgs e, WEStyle style, string str)
 {
 }