Exemple #1
0
 /// <summary>Paint the intermediate layer of the display, graphics that changes infrequently 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>
 public static void PaintUnits <THex>(this MapDisplay <THex> @this, Graphics graphics) where THex : MapGridHex
 {
     if (@this == null)
     {
         throw new ArgumentNullException("this");
     }
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     /* NO-OP - Not implemented in examples. */
 }
Exemple #2
0
        /// <summary>Paint the destination indicator for the current shortest path.</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>The current graphics origin must be the centre of the current hex.</remarks>
        static void PaintPathDestination <THex>(this MapDisplay <THex> @this, Graphics graphics
                                                ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            var unit = @this.GridSize.Height / 8.0F;

            graphics.DrawLine(Pens.Black, -unit * 2, -unit * 2, unit * 2, unit * 2);
            graphics.DrawLine(Pens.Black, -unit * 2, unit * 2, unit * 2, -unit * 2);
        }
Exemple #3
0
 /// <summary>Paints all the hexes in <paramref name="clipHexes"/> by executing <paramref name="paintAction"/>
 /// for each hex on <paramref name="graphics"/>.</summary>
 /// <param name="this">Type: MapDisplay{THex} - The map to be painted.</param>
 /// <param name="graphics">Graphics object for the canvas being painted.</param>
 /// <param name="clipHexes">Type: CoordRectangle -
 /// The rectangular extent of hexes to be painted.</param>
 /// <param name="paintAction">Type: Action {HexCoords} -
 /// The paint action to be performed for each hex.</param>
 public static void PaintForEachHex <THex>(this MapDisplay <THex> @this, Graphics graphics,
                                           CoordsRectangle clipHexes, Action <HexCoords> paintAction
                                           ) where THex : MapGridHex
 {
     @this.ForEachHex(hex => {
         if (clipHexes.Left <= hex.Coords.User.X && hex.Coords.User.X <= clipHexes.Right &&
             clipHexes.Top <= hex.Coords.User.Y && hex.Coords.User.Y <= clipHexes.Bottom)
         {
             graphics.Transform = @this.TranslateToHex(hex.Coords);
             paintAction(hex.Coords);
         }
     });
     return;
 }
Exemple #4
0
        /// <summary>Paint the direction arrow for each hex of the current shortest path.</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>
        /// <param name="hexside">Type: <see cref="Hexside"/> -
        /// Direction from this hex in which the next step is made.</param>
        /// <remarks>The current graphics origin must be the centre of the current hex.</remarks>
        static void PaintPathArrow <THex>(this MapDisplay <THex> @this, Graphics graphics, Hexside hexside
                                          ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            var unit = @this.GridSize.Height / 8.0F;

            graphics.RotateTransform(60 * (int)hexside);
            graphics.DrawLine(Pens.Black, 0, unit * 4, 0, -unit);
            graphics.DrawLine(Pens.Black, 0, unit * 4, -unit * 3 / 2, unit * 2);
            graphics.DrawLine(Pens.Black, 0, unit * 4, unit * 3 / 2, unit * 2);
        }
Exemple #5
0
        /// <summary>Paint the direction and destination indicators for each hex of the current shortest path.</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>
        /// <param name="path">Type: <see cref="IDirectedPathCollection"/> -
        /// A directed path (ie linked-list> of hexes to be highlighted with a direction arrow.</param>
        static void PaintPathArrow <THex>(this MapDisplay <THex> @this, Graphics graphics, IDirectedPathCollection path
                                          ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            graphics.TranslateTransform(@this.CentreOfHexOffset.Width, @this.CentreOfHexOffset.Height);
            if (path.PathSoFar == null)
            {
                @this.PaintPathDestination(graphics);
            }
            else
            {
                @this.PaintPathArrow(graphics, path.PathStep.HexsideEntry);
            }
        }
Exemple #6
0
        /// <summary>Paint the current shortese path.</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>
        /// <param name="path">Type: <see cref="IDirectedPathCollection"/> -
        /// A directed path (ie linked-list> of hexes to be painted.</param>
        public static void PaintPath <THex>(this MapDisplay <THex> @this, Graphics graphics, IDirectedPathCollection path
                                            ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            using (var brush = new SolidBrush(Color.FromArgb(78, Color.PaleGoldenrod))) {
                while (path != null)
                {
                    var coords = path.PathStep.Hex.Coords;
                    graphics.Transform = @this.TranslateToHex(coords);
                    graphics.FillPath(brush, @this.HexgridPath);

                    if (@this.ShowPathArrow)
                    {
                        @this.PaintPathArrow(graphics, path);
                    }

                    path = path.PathSoFar;
                }
            }
        }
Exemple #7
0
        public static void PaintShading <THex>(this MapDisplay <THex> @this, Graphics graphics
                                               ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            var container = graphics.BeginContainer();

            if (@this.ShowFov)
            {
                var clipHexes = @this.GetClipInHexes(graphics.VisibleClipBounds);
                using (var shadeBrush = new SolidBrush(Color.FromArgb(@this.ShadeBrushAlpha, @this.ShadeBrushColor))) {
                    @this.PaintForEachHex(graphics, clipHexes, coords => {
                        if (@this.Fov != null && [email protected][coords])
                        {
                            graphics.FillPath(shadeBrush, @this.HexgridPath);
                        }
                    });
                }
            }

            graphics.EndContainer(container);
        }