Exemplo n.º 1
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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * get a texture brush based on region's brush attributes.
         * @param brush the map brush object.
         * @return the texture brush to used for the map brush.
         */
        private TextureBrush GetImagePatternBrush(MapBrush brush)
        {
            switch (brush.Pattern)
            {
                case 1:
                    break;
                case 2:
                    _imagePatternGraphics.SetColor(brush.ForeColor);
                    _imagePatternGraphics.FillRect( 0, 0, IMAGE_PATERN_WIDTH,
                            IMAGE_PATERN_WIDTH);
                    break;
                case 3:
                case 19:
                case 20:
                case 21:
                case 22:
                case 23:
                    _imagePatternGraphics.SetColor(brush.BackColor);
                    _imagePatternGraphics.FillRect( 0, 0, IMAGE_PATERN_WIDTH,
                            IMAGE_PATERN_WIDTH);

                    for (int i = 0; i < 4; i++)
                    {
                        _imagePatternGraphics.DrawLine(0, i * 4, IMAGE_PATERN_WIDTH, i * 4);
                    }
                    break;
                case 4:
                case 24:
                case 25:
                case 26:
                case 27:
                case 28:
                    _imagePatternGraphics.SetColor(brush.BackColor);
                    _imagePatternGraphics.FillRect( 0, 0, IMAGE_PATERN_WIDTH,
                            IMAGE_PATERN_WIDTH);
                    _imagePatternGraphics.SetColor(brush.ForeColor);
                    for (int i = 0; i < 4; i++)
                    {
                        _imagePatternGraphics.DrawLine(i * 4, 0, i * 4, IMAGE_PATERN_WIDTH);
                    }
                    break;
                case 5:
                case 29:
                case 30:
                case 31:
                case 32:
                case 33:
                    _imagePatternGraphics.SetColor(brush.BackColor);
                    _imagePatternGraphics.FillRect( 0, 0, IMAGE_PATERN_WIDTH,
                           IMAGE_PATERN_WIDTH);
                    _imagePatternGraphics.SetColor(brush.ForeColor);
                    for (int i = 0; i < 8; i++)
                    {
                        _imagePatternGraphics.DrawLine(0, i * 4, i * 4, 0);
                    }
                    break;
                case 6:
                case 34:
                case 35:
                case 36:
                case 37:
                case 38:
                    _imagePatternGraphics.SetColor(brush.BackColor);
                    _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                           IMAGE_PATERN_WIDTH);
                    _imagePatternGraphics.SetColor(brush.ForeColor);
                    for (int i = 0; i < 8; i++)
                    {
                        _imagePatternGraphics.DrawLine(0, IMAGE_PATERN_WIDTH - i * 4, i * 4, 0);
                    }
                    break;
                case 15:
                case 16:
                case 17:
                case 18:
                case 48:
                case 49:
                case 50:
                case 51:
                case 53:
                    _imagePatternGraphics.SetColor(brush.BackColor);
                    _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                           IMAGE_PATERN_WIDTH);
                    _imagePatternGraphics.SetColor(brush.ForeColor);
                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            _imagePatternGraphics.FillRect(i * 4, j * 4, 1, 1);
                        }
                    }
                    break;
                default:
                    _imagePatternGraphics.SetColor(brush.BackColor);
                    _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                           IMAGE_PATERN_WIDTH);
                    _imagePatternGraphics.SetColor(brush.ForeColor);
                    for (int i = 0; i < 4; i++)
                    {
                        _imagePatternGraphics.DrawLine(0, i * 4, IMAGE_PATERN_WIDTH, i * 4);
                        _imagePatternGraphics.DrawLine(i * 4, 0, i * 4, IMAGE_PATERN_WIDTH);
                    }

                    break;

            }

            int[] rgbData = _imagePattern.GetRGB();

            TextureBrush textureBrush = new TextureBrush(rgbData, IMAGE_PATERN_WIDTH, IMAGE_PATERN_WIDTH);

            return textureBrush;
        }
Exemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get a texture brush based on region's brush attributes.
         * @param brush the map brush object.
         * @return the texture brush to used for the map brush.
         */

        private TextureBrush GetImagePatternBrush(MapBrush brush)
        {
            switch (brush.Pattern)
            {
            case 1:
                break;

            case 2:
                _imagePatternGraphics.SetColor(brush.ForeColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);
                break;

            case 3:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
                _imagePatternGraphics.SetColor(brush.BackColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);

                for (int i = 0; i < 4; i++)
                {
                    _imagePatternGraphics.DrawLine(0, i * 4, IMAGE_PATERN_WIDTH, i * 4);
                }
                break;

            case 4:
            case 24:
            case 25:
            case 26:
            case 27:
            case 28:
                _imagePatternGraphics.SetColor(brush.BackColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);
                _imagePatternGraphics.SetColor(brush.ForeColor);
                for (int i = 0; i < 4; i++)
                {
                    _imagePatternGraphics.DrawLine(i * 4, 0, i * 4, IMAGE_PATERN_WIDTH);
                }
                break;

            case 5:
            case 29:
            case 30:
            case 31:
            case 32:
            case 33:
                _imagePatternGraphics.SetColor(brush.BackColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);
                _imagePatternGraphics.SetColor(brush.ForeColor);
                for (int i = 0; i < 8; i++)
                {
                    _imagePatternGraphics.DrawLine(0, i * 4, i * 4, 0);
                }
                break;

            case 6:
            case 34:
            case 35:
            case 36:
            case 37:
            case 38:
                _imagePatternGraphics.SetColor(brush.BackColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);
                _imagePatternGraphics.SetColor(brush.ForeColor);
                for (int i = 0; i < 8; i++)
                {
                    _imagePatternGraphics.DrawLine(0, IMAGE_PATERN_WIDTH - i * 4, i * 4, 0);
                }
                break;

            case 15:
            case 16:
            case 17:
            case 18:
            case 48:
            case 49:
            case 50:
            case 51:
            case 53:
                _imagePatternGraphics.SetColor(brush.BackColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);
                _imagePatternGraphics.SetColor(brush.ForeColor);
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        _imagePatternGraphics.FillRect(i * 4, j * 4, 1, 1);
                    }
                }
                break;

            default:
                _imagePatternGraphics.SetColor(brush.BackColor);
                _imagePatternGraphics.FillRect(0, 0, IMAGE_PATERN_WIDTH,
                                               IMAGE_PATERN_WIDTH);
                _imagePatternGraphics.SetColor(brush.ForeColor);
                for (int i = 0; i < 4; i++)
                {
                    _imagePatternGraphics.DrawLine(0, i * 4, IMAGE_PATERN_WIDTH, i * 4);
                    _imagePatternGraphics.DrawLine(i * 4, 0, i * 4, IMAGE_PATERN_WIDTH);
                }


                break;
            }

            int[] rgbData = _imagePattern.GetRGB();

            TextureBrush textureBrush = new TextureBrush(rgbData, IMAGE_PATERN_WIDTH, IMAGE_PATERN_WIDTH);


            return(textureBrush);
        }