/// <summary>
        /// 更改断点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Changbreak_Click(object sender, EventArgs e)
        {
            int count = DG_break.RowCount - 1;
            ClassBreakRenderer renderer = (ClassBreakRenderer)slayer.Renderer;
            List <double>      newbreak = new List <double>();

            newbreak.Add(renderer.MinValue);
            newbreak.Add(renderer.MaxValue);
            try
            {
                for (int i = 0; i < count; i++)
                {
                    double value = Convert.ToDouble(DG_break[1, i].Value);
                    if (value > renderer.MinValue && value < renderer.MaxValue)
                    {
                        newbreak.Add(value);
                    }
                }
                newbreak = newbreak.Distinct().ToList();
                newbreak.Sort();
                newbreak.RemoveAt(0);
                newbreak.RemoveAt(newbreak.Count - 1);

                if (RB_1.Checked == true)
                {
                    CB_color.Enabled = true;
                    ((ClassBreakRenderer)slayer.Renderer).Mode = 1;
                    ((ClassBreakRenderer)slayer.Renderer).ClassBreakChange(newbreak);
                    Bitmap newcolor   = new Bitmap(CB_color.Image);
                    Color  startcolor = newcolor.GetPixel(1, newcolor.Height / 2);
                    Color  endcolor   = newcolor.GetPixel(newcolor.Width - 1, newcolor.Height / 2);
                    ((ClassBreakRenderer)slayer.Renderer).SetColor(startcolor, endcolor);
                }
                else
                {
                    CB_color.Enabled = false;
                    ((ClassBreakRenderer)slayer.Renderer).Mode = 2;
                    ((ClassBreakRenderer)slayer.Renderer).ClassBreakChange(newbreak);
                }

                ShowSymbols(slayer);
                ShowBreaks();
            }
            catch
            {
                MessageBox.Show("错误,出现异常");
                ShowBreaks();
            }
        }
示例#2
0
        public void Save(string save_path)
        {
            _filepath = save_path;
            FileStream   fs = new FileStream(_filepath, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            string line = _map.MapName + " " + _Geocoordinate.ToString() + " " + _Procoordinate.ToString() + " "
                          + _ratio.ToString("F2") + " " + _scaleindex.ToString() + " " + CenterPos.X.ToString() + " " + CenterPos.Y.ToString() + " " + _map.LayerNum.ToString();

            sw.WriteLine(line);
            //对每一图层
            for (int i = 0; i < _map.LayerNum; i++)
            {
                sw.WriteLine(_map.Layers[i].FilePath);
                sw.WriteLine(_map.Layers[i].Visible.ToString());

                switch (_map.Layers[i].rendertype)
                {
                //唯一值渲染
                case RendererType.UniqueValueRenderer:
                    UniqueValueRenderer Urenderer = (UniqueValueRenderer)_map.Layers[i].Renderer;
                    string filename_uvr           = _map.Layers[i].rendertype.ToString() + " " + Urenderer.Field;
                    sw.WriteLine(filename_uvr);
                    break;

                //分级渲染
                case RendererType.ClassBreakRenderer:
                    ClassBreakRenderer Crenderer    = (ClassBreakRenderer)_map.Layers[i].Renderer;
                    string             filename_cbr = _map.Layers[i].rendertype.ToString() + " " + Crenderer.Field;
                    sw.WriteLine(filename_cbr);
                    break;

                //简单渲染
                default:
                    sw.WriteLine(_map.Layers[i].rendertype.ToString());
                    break;
                }

                //判断是否有注记信息
                bool hastext = _map.Layers[i].HasText;
                sw.WriteLine(hastext.ToString());
                if (hastext == true)
                {
                    sw.WriteLine(_map.Layers[i].Textrender.Field);
                }
            }
            sw.Close();
            fs.Close();
        }
        /// <summary>
        /// 显示断点表格
        /// </summary>
        private void ShowBreaks()
        {
            ClassBreakRenderer renderer = (ClassBreakRenderer)slayer.Renderer;

            if (renderer.Mode == 1)
            {
                RB_1.Checked = true;
            }
            else
            {
                RB_2.Checked = true;
            }
            if (DG_break.RowCount == 0)
            {
                CB_color.Image = new Bitmap(((ClassBreakRenderer)slayer.Renderer).ShowLinearGradient(), CB_color.Size);
            }
            int sFieldCount = renderer.BreakCount;

            DG_break.RowCount = sFieldCount + 3;
            for (int i = 0; i < sFieldCount + 2; i++)
            {
                //显示值
                if (i == 0)
                {
                    DG_break[0, i].Value = "Min";
                    DG_break[1, i].Value = renderer.MinValue;
                }
                else if (i != sFieldCount + 1)
                {
                    DG_break[0, i].Value = i.ToString();
                    DG_break[1, i].Value = renderer.Breaks[i - 1];
                }
                else
                {
                    DG_break[0, i].Value = "Max";
                    DG_break[1, i].Value = renderer.MaxValue;
                }
            }
        }
示例#4
0
        /// <summary>
        /// 画单个图层方法
        /// </summary>
        /// <param name="g"></param>
        /// <param name="layer"></param>
        /// <param name="start"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        private Point LegendOfLayer(Graphics g, Map.MyLayer layer, Point start, double resizescale)
        {
            int   layerdis = (int)(20 * resizescale);
            int   leftdis  = (int)(resizescale * 8);
            int   columdis = (int)(resizescale * 12);
            int   rowdis   = (int)(resizescale * 10);
            Point nowstart = new Point(start.X + leftdis, start.Y + layerdis);

            g.DrawString(layer.LayerName, new Font("黑体", (float)(resizescale * 10)), Brushes.Black, nowstart);
            nowstart.Y += ((int)(resizescale * 10) + rowdis);
            Font regularfont = new Font("宋体", (float)(resizescale * 9));
            int  symbolcount = layer.Renderer.SymbolCount;

            switch (layer.rendertype)
            {
            case MyRenderer.RendererType.UniqueValueRenderer:
                UniqueValueRenderer urenderer = (UniqueValueRenderer)layer.Renderer;
                for (int i = 0; i < symbolcount; i++)
                {
                    Bitmap autoubit = urenderer.FindSymbolByIndex(i).GetBitmap();
                    Image  uimg     = new Bitmap(autoubit, new Size((int)(resizescale * autoubit.Width), (int)(resizescale * autoubit.Height)));
                    g.DrawImage(uimg, nowstart);
                    g.DrawString(urenderer.FindValue(i), regularfont, Brushes.Black, new Point(nowstart.X + (int)(resizescale * 42) + columdis, nowstart.Y + (int)(resizescale * 6)));
                    nowstart.Y += (int)(resizescale * 24) + rowdis;
                }
                break;

            case MyRenderer.RendererType.ClassBreakRenderer:
                ClassBreakRenderer crenderer = (ClassBreakRenderer)layer.Renderer;
                for (int i = 0; i < symbolcount; i++)
                {
                    Bitmap autocbit = crenderer.FindSymbolByIndex(i).GetBitmap();
                    Image  cimg     = new Bitmap(autocbit, new Size((int)(resizescale * autocbit.Width), (int)(resizescale * autocbit.Height)));
                    g.DrawImage(cimg, nowstart);

                    string value;
                    if (i == 0)
                    {
                        value = crenderer.MinValue.ToString() + " - " + crenderer.Breaks[i].ToString();
                    }
                    else if (i != crenderer.BreakCount)
                    {
                        value = crenderer.Breaks[i - 1].ToString() + " - " + crenderer.Breaks[i].ToString();
                    }
                    else
                    {
                        value = crenderer.Breaks[i - 1].ToString() + " - " + crenderer.MaxValue.ToString();
                    }

                    g.DrawString(value, regularfont, Brushes.Black, new Point((nowstart.X + (int)(resizescale * 42) + columdis), (nowstart.Y + (int)(resizescale * 6))));

                    nowstart.Y += (int)(resizescale * 24) + rowdis;
                }
                break;

            default:
                SimpleRenderer srenderer = (SimpleRenderer)layer.Renderer;
                Bitmap         autosbit  = srenderer.SymbolStyle.GetBitmap();
                Image          simg      = new Bitmap(autosbit, new Size((int)(resizescale * autosbit.Width), (int)(resizescale * autosbit.Height)));
                g.DrawImage(simg, nowstart);

                g.DrawString(layer.LayerName, regularfont, Brushes.Black, new Point((nowstart.X + (int)(resizescale * 42) + columdis), (nowstart.Y + (int)(resizescale * 6))));
                nowstart.Y += ((int)(resizescale * 24) + rowdis);
                break;
            }
            return(nowstart);
        }