Exemple #1
0
        /// <summary>Paint the base layer of the display, graphics that changes rarely between refreshes.</summary>
        /// <param name="this">Type: MapDisplay{THex} - The map to be painted.</param>
        /// <param name="graphics">Type: Graphics - Object representing the canvas being painted.</param>
        /// <remarks>For each visible hex: perform <c>paintAction</c> and then draw its hexgrid outline.</remarks>
        public static void PaintMap <THex>(this MapDisplay <THex> @this, Graphics graphics
                                           ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            var container = graphics.BeginContainer(); // Set all transformations relative to current origin!
            var clipHexes = @this.GetClipInHexes(graphics.VisibleClipBounds);

            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            var font       = SystemFonts.MenuFont;
            var brush      = Brushes.Black;
            var textOffset = new Point((@this.GridSize.Scale(0.50F)
                                        - new SizeF(font.Size, font.Size).Scale(0.8F)).ToSize());

            @this.PaintForEachHex(graphics, clipHexes, coords => {
                @this[coords].Paint(graphics);
                if (@this.ShowHexgrid)
                {
                    graphics.DrawPath(Pens.Black, @this.HexgridPath);
                }
                if (@this.LandmarkToShow > 0)
                {
                    graphics.DrawString(@this.LandmarkDistance(coords, @this.LandmarkToShow - 1), font, brush, textOffset);
                }
            });
            graphics.EndContainer(container);
        }