コード例 #1
0
        private Point[] DrawPline(MapPen mapPen, GeoPolyline pline)
        {
            ArrayList clippedPts = _sutherlandHodgman.ClipPline(pline.GetPoints());

            GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts);
            if (screenPts.Length > 1)
            {
                {
                    Pen   pen     = GetPen(mapPen);
                    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;
                    }

                    Point[] points = new Point[xpoints.Length];
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] = new Point(xpoints[i], ypoints[i]);
                    }
                    SharedGraphics2D.Graphics.DrawLines(pen, points);
                    return(points);
                }
            }
            return(null);
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a pline.
         * @param mapPen the pen used to draw the polyline
         * @param pline the polyline object.
         */

        private void DrawPline(MapPen mapPen, GeoPolyline pline)
        {
            ArrayList clippedPts = _sutherlandHodgman.ClipPline(pline.GetPoints());

            GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts);
            if (screenPts.Length > 1)
            {
                {
                    int penWidth = mapPen.Width;
                    if (mapPen.Pattern > 62)
                    {
                        penWidth = mapPen.Width * 2;
                    }
                    Pen pen = new Pen(new Color(mapPen.Color, false), penWidth);
                    SharedGraphics2D.SetDefaultPen(pen);
                    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;
                    }
                    Polyline polyline = new Polyline
                    {
                        Xpoints     = xpoints,
                        Ypoints     = ypoints,
                        NumOfPoints = xpoints.Length
                    };

                    SharedGraphics2D.DrawPolyline(null, polyline);
                }
            }
        }
コード例 #3
0
        private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region)
        {
            Pen       pen        = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), mapPen.Width);
            Brush     brush      = GetBrush(mapBrush);
            GeoBounds bounds     = new GeoBounds(118.808451, 31.907395, 0.003907, 0.0035);
            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;
                    }

                    Point[] points = new Point[xpoints.Length];
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] = new Point(xpoints[i], ypoints[i]);
                    }
                    SharedGraphics2D.Graphics.DrawPolygon(pen, points);
                    SharedGraphics2D.Graphics.FillPolygon(brush, points);
                }
            }
        }
コード例 #4
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);
                    }
                }
            }
        }
コード例 #5
0
        private static Pen GetPen(MapPen mapPen)
        {
            Bitmap patternBitmap = new Bitmap(4, 4);
            int    penWidth      = mapPen.Width;

            if (mapPen.Pattern > 62)
            {
                penWidth = mapPen.Width * 4;
            }


            Pen pen = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), penWidth);

            switch (mapPen.Pattern)
            {
            case 0:
            case 1:
                break;

            case 63:
            case 64:
                pen.CompoundArray = new float[] { 0, 0.25f, 0.5f, 0.75f };
                break;

            case 72:
            case 73:
            case 74:
            case 75:
            case 76:
            case 77:
                pen.DashPattern = new float[] { 3f, 3f, 3f, 3f };
                break;

            default:
                break;
            }
            return(pen);
        }
コード例 #6
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);
                    }
                }
            }
        }
コード例 #7
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * draw a pline.
         * @param mapPen the pen used to draw the polyline
         * @param pline the polyline object.
         */
        private void DrawPline(MapPen mapPen, GeoPolyline pline)
        {
            ArrayList clippedPts = _sutherlandHodgman.ClipPline(pline.GetPoints());
            GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts);
            if (screenPts.Length > 1)
            {
                {
                    int penWidth = mapPen.Width;
                    if (mapPen.Pattern > 62)
                    {
                        penWidth = mapPen.Width * 2;
                    }
                    Pen pen = new Pen(new Color(mapPen.Color,false), penWidth);
                    SharedGraphics2D.SetDefaultPen(pen);
                    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;

                    }
                    Polyline polyline = new Polyline
                                            {
                                                Xpoints = xpoints,
                                                Ypoints = ypoints,
                                                NumOfPoints = xpoints.Length
                                            };

                    SharedGraphics2D.DrawPolyline(null, polyline);
                }

            }
        }
コード例 #8
0
ファイル: MapPen.cs プロジェクト: 237rxd/maptiledownloader
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Copy constructor.
  * @param pen  the map object copied from.
  */
 public MapPen(MapPen pen)
 {
     Width = pen.Width;
     Pattern = pen.Pattern;
     Color = pen.Color;
 }
コード例 #9
0
        private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region)
        {
            Pen pen = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), mapPen.Width);
            Brush brush = GetBrush(mapBrush);
            GeoBounds bounds = new GeoBounds(118.808451, 31.907395, 0.003907, 0.0035);
            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;

                    }

                    Point[] points = new Point[xpoints.Length];
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] = new Point(xpoints[i], ypoints[i]);
                    }
                    SharedGraphics2D.Graphics.DrawPolygon(pen, points);
                    SharedGraphics2D.Graphics.FillPolygon(brush, points);
                }
            }
        }
コード例 #10
0
        private Point[] DrawPline(MapPen mapPen, GeoPolyline pline)
        {
            ArrayList clippedPts = _sutherlandHodgman.ClipPline(pline.GetPoints());
            GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts);
            if (screenPts.Length > 1)
            {
                {

                    Pen pen = GetPen(mapPen);
                    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;

                    }

                    Point[] points = new Point[xpoints.Length];
                    for(int i=0;i<points.Length;i++)
                    {
                        points[i] = new Point(xpoints[i], ypoints[i]);
                    }
                    SharedGraphics2D.Graphics.DrawLines(pen, points);
                    return points;
                }

            }
            return null;
        }
コード例 #11
0
        private static Pen GetPen(MapPen mapPen)
        {
            Bitmap patternBitmap = new Bitmap(4, 4);
            int penWidth = mapPen.Width;
            if (mapPen.Pattern > 62)
            {
                penWidth = mapPen.Width * 4;
            }

            Pen pen = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), penWidth);
            switch(mapPen.Pattern)
            {
                case 0:
                case 1:
                    break;
                case 63:
                case 64:
                    pen.CompoundArray = new float[] {0,0.25f,0.5f,0.75f};
                    break;
                case 72:
                case 73:
                case 74:
                case 75:
                case 76:
                case 77:
                    pen.DashPattern = new float[] { 3f, 3f, 3f, 3f };
                    break;
                default:
                    break;

            }
            return pen;
        }
コード例 #12
0
ファイル: MapPen.cs プロジェクト: xuyibin/maptiledownloader
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param pen  the map object copied from.
         */
        public MapPen(MapPen pen)
        {
            Width   = pen.Width;
            Pattern = pen.Pattern;
            Color   = pen.Color;
        }