Example #1
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);
            }
        }
Example #2
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;
                }
            }
        }