示例#1
0
        private void Class_Apply_Click(object sender, EventArgs e)
        {
            WEMapObjects.WEClassBreaksRender newStyle = new WEMapObjects.WEClassBreaksRender();
            newStyle.SymbolMethod = 3;
            newStyle.Field        = Class_Field.SelectedItem.ToString();
            newStyle.BreakCount   = Convert.ToInt32(ClassNum.SelectedItem);
            if (_mapType == 1)
            {
                newStyle.SymbolStyle   = Class_symbol.SelectedIndex + 1;
                newStyle.FromColor     = Class_FromColor.BackColor;               //起始颜色
                newStyle.ToColor       = Class_ToColor.BackColor;                 //终止颜色
                newStyle.BoundaryWidth = Convert.ToDouble(Single_bdrWidth.Value); //边界线宽
                newStyle.BoundaryColor = Class_bdrColor.BackColor;                //边界颜色
                newStyle.FromSize      = Convert.ToDouble(Class_FromSize);        //起始尺寸
                newStyle.ToSize        = Convert.ToDouble(Class_ToSize);          //终止尺寸
            }
            if (_mapType == 2)
            {
                newStyle.SymbolStyle = Class_symbol.SelectedIndex;
                newStyle.FromColor   = Class_FromColor.BackColor;        //起始颜色
                newStyle.ToColor     = Class_ToColor.BackColor;          //终止颜色
                newStyle.FromSize    = Convert.ToDouble(Class_FromSize); //起始尺寸
                newStyle.ToSize      = Convert.ToDouble(Class_ToSize);   //终止尺寸
            }
            if (_mapType == 3)
            {
                newStyle.FromColor     = Class_FromColor.BackColor;               //起始颜色
                newStyle.ToColor       = Class_ToColor.BackColor;                 //终止颜色
                newStyle.BoundaryWidth = Convert.ToDouble(Single_bdrWidth.Value); //边界线宽
                newStyle.BoundaryColor = Class_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[]
        }
示例#2
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);
            }
        }