Esempio n. 1
0
        /// <summary>
        /// Draws the map regions to the graphics surface. The surface must
        /// have a transform applied to it to translate the Dereth coordinate
        /// space to the image's pixel coordinate space.
        /// </summary>
        public static void DrawRegions(Graphics g, Brush regionFill, Brush innerRegionFill)
        {
            LazyLoadRegions();
            System.Drawing.Drawing2D.GraphicsPath path      = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.GraphicsPath innerPath = new System.Drawing.Drawing2D.GraphicsPath();

            foreach (Polygon poly in mPolygonRegions)
            {
                path.AddPolygon(poly.Points);
            }
            if (mRectangleRegions.Length > 0)
            {
                path.AddRectangles(mRectangleRegions);
            }

            foreach (Polygon innerPoly in mInnerPolygonRegions)
            {
                innerPath.AddPolygon(innerPoly.Points);
            }
            if (mInnerRectangleRegions.Length > 0)
            {
                innerPath.AddRectangles(mInnerRectangleRegions);
            }

            Region region      = new Region(path);
            Region innerRegion = new Region(innerPath);

            region.Exclude(innerRegion);

            g.FillRegion(regionFill, region);
            g.FillRegion(innerRegionFill, innerRegion);
        }