Example #1
0
 private void PolygonSymbolSelect_Load()
 {
     btn_color.BackColor = polygonsymbol.GetColor();
     ShowSymbol();
     listview_Load();
     CB_size_Load();
     if (polygonsymbol.GetColor() != polygonsymbol.LineStyle.GetColor())
     {
         HasBoundary.Checked = true;
     }
     foreach (Control c in this.SymbolListView.Controls)
     {
         c.MouseClick += C_DoubleClick;
     }
 }
Example #2
0
        /// <summary>
        /// 唯一值渲染和分级渲染时的绘制要素
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <param name="centerPos"></param>
        /// <param name="scale"></param>
        /// <param name="fid2Symbol"></param>
        internal override void DrawSpaceData(Graphics g, Rectangle bounds, PointF centerPos, double scale, Dictionary <int, Symbol> fid2Symbol)
        {
            //选中要素的样式
            Pen selectedPen = new Pen(Color.Cyan);

            selectedPen.Width = 2.5F;

            MyPoint xyCenter = ETCProjection.LngLat2XY(new MyPoint(centerPos.X, centerPos.Y));
            double  xmin     = xyCenter.X - scale * bounds.Width / 2;
            double  xmax     = xyCenter.X + scale * bounds.Width / 2;
            double  ymin     = xyCenter.Y - scale * bounds.Height / 2;
            double  ymax     = xyCenter.Y + scale * bounds.Height / 2;

            for (int i = 0; i < polygons.Count; i++)
            {
                //从symbol中获取样式
                PolygonSymbol ps      = (PolygonSymbol)fid2Symbol[polygons[i].FID];
                Pen           mypen   = ps.LineStyle.GetPen;
                Brush         mybrush = new SolidBrush(ps.GetColor());

                List <int> parts = new List <int>(polygons[i].firstIndex);
                parts.Add(polygons[i].PointCount);
                for (int k = 0; k < polygons[i].firstIndex.Length; k++)  //对于每一个MultiPolygon的子多边形
                {
                    List <PointF> pointfs = new List <PointF>();
                    for (int j = parts[k]; j < parts[k + 1]; j++)  //对于每一个MultiPolygon的子多边形的每一个点
                    {
                        MyPoint xyProjection = ETCProjection.LngLat2XY(polygons[i].Points[j]);
                        double  xScreen      = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin);
                        double  yScreen      = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin);
                        PointF  p            = new PointF((float)xScreen, bounds.Height - (float)yScreen);
                        pointfs.Add(p);
                    }
                    if (GeometryTools.IsPointsPartInRectangle(pointfs.ToArray(), new MyRectangle(bounds.X, bounds.Width, bounds.Y, bounds.Height)) == true)
                    {
                        g.DrawPolygon(mypen, pointfs.ToArray());
                        g.FillPolygon(mybrush, pointfs.ToArray());
                    }
                }
            }
            for (int i = 0; i < polygons.Count; i++)
            {
                if (polygons[i].Selected == true)
                {
                    List <int> parts = new List <int>(polygons[i].firstIndex);
                    parts.Add(polygons[i].PointCount);
                    for (int k = 0; k < polygons[i].firstIndex.Length; k++)  //对于每一个MultiPolygon的子多边形
                    {
                        List <PointF> pointfs = new List <PointF>();
                        for (int j = parts[k]; j < parts[k + 1]; j++)
                        {
                            MyPoint xyProjection = ETCProjection.LngLat2XY(polygons[i].Points[j]);
                            double  xScreen      = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin);
                            double  yScreen      = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin);
                            PointF  p            = new PointF((float)xScreen, bounds.Height - (float)yScreen);
                            pointfs.Add(p);
                        }
                        if (GeometryTools.IsPointsPartInRectangle(pointfs.ToArray(), new MyRectangle(bounds.X, bounds.Width, bounds.Y, bounds.Height)) == true)
                        {
                            g.DrawPolygon(selectedPen, pointfs.ToArray());  //画选中多边形的轮廓
                        }
                    }
                }
            }
        }