Ejemplo n.º 1
0
        protected override void Paint(UMD.HCIL.PocketPiccolo.Util.PPaintContext paintContext)
        {
            Graphics2D g = paintContext.Graphics;

            if (points.Count > 0)
            {
                if (Brush != null && closed)
                {
                    g.FillPolygon(Brush, (PointF[])points.ToArray(typeof(PointF)));
                }

                if (pen != null)
                {
                    if (closed)
                    {
                        g.DrawPolygon(pen, (PointF[])points.ToArray(typeof(PointF)));
                    }
                    else
                    {
                        for (int i = 0; i < points.Count - 1; i++)
                        {
                            g.DrawLine(pen, (PointF)points[i], (PointF)points[i + 1]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a region.
         * @param mapPen  pen for the border of the region.
         * @param mapBrush brush to fill the region.
         * @param region the polygon object.
         */

        private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region)
        {
            Pen          pen        = new Pen(new Color(mapPen.Color, false), mapPen.Width);
            TextureBrush brush      = GetImagePatternBrush(mapBrush);
            ArrayList    clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints());

            GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts);

            if (screenPts.Length > 2)
            {
                {
                    int[] xpoints = new int[screenPts.Length];
                    int[] ypoints = new int[screenPts.Length];
                    for (int i = 0; i < screenPts.Length; i++)
                    {
                        xpoints[i] = (int)screenPts[i].X;
                        ypoints[i] = (int)screenPts[i].Y;
                    }
                    Polygon polygon = new Polygon
                    {
                        Xpoints      = xpoints,
                        Ypoints      = ypoints,
                        NumOfNpoints = xpoints.Length
                    };

                    if (mapBrush.Pattern == 2)
                    {
                        SharedGraphics2D.SetPenAndBrush(pen, brush);
                        SharedGraphics2D.DrawPolygon(null, polygon);
                        SharedGraphics2D.FillPolygon(null, polygon);
                    }
                    else
                    {
                        SharedGraphics2D.SetDefaultPen(pen);
                        SharedGraphics2D.DrawPolygon(null, polygon);
                    }
                }
            }
        }