Exemple #1
0
        /// <summary>Paint the top layer of the display, graphics that changes frequently between refreshes.</summary>
        /// <param name="this">Type: MapDisplay{THex} - The map to be painted.</param>
        /// <param name="graphics">Graphics object for the canvas being painted.</param>
        public static void PaintHighlight <THex>(this MapDisplay <THex> @this, Graphics graphics
                                                 ) where THex : MapGridHex
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            var container = graphics.BeginContainer();

            graphics.Transform = @this.TranslateToHex(@this.StartHex);
            graphics.DrawPath(Pens.Red, @this.HexgridPath);

            if (@this.ShowPath)
            {
                graphics.EndContainer(container); container = graphics.BeginContainer();
                @this.PaintPath(graphics, @this.Path);
            }

            if (@this.ShowRangeLine)
            {
                graphics.EndContainer(container); container = graphics.BeginContainer();
                var target = @this.CentreOfHex(@this.HotspotHex);
                graphics.DrawLine(Pens.Red, @this.CentreOfHex(@this.StartHex), target);
                graphics.DrawLine(Pens.Red, target.X - 8, target.Y - 8, target.X + 8, target.Y + 8);
                graphics.DrawLine(Pens.Red, target.X - 8, target.Y + 8, target.X + 8, target.Y - 8);
            }
            graphics.EndContainer(container);
        }