/// <summary>Returns a DirectedPath composed by extending this DirectedPath by one hex.</summary>
 internal DirectedPathCollection(IDirectedPathCollection pathSoFar, DirectedPathStepHex pathStep, int totalCost)
 {
     PathStep   = pathStep;
     PathSoFar  = pathSoFar;
     TotalCost  = totalCost;
     TotalSteps = pathSoFar == null ? 0 : pathSoFar.TotalSteps + 1;
 }
Example #2
0
        /// <summary>Paint the direction and destination indicators for each hex of the current shortest path.</summary>
        /// <param name="dc">Type: Graphics - Object representing the canvas being painted.</param>
        /// <param name="path">Type: <see cref="IDirectedPath"/> -
        /// A directed path (ie linked-list> of hexes to be highlighted with a direction arrow.</param>
        protected virtual void PaintPathArrow(DrawingContext graphics, IDirectedPathCollection path)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            graphics.PushTransform(new TranslateTransform(CentreOfHexOffset.Width, CentreOfHexOffset.Height));
            if (path.PathSoFar == null)
            {
                PaintPathDestination(graphics);
            }
            else
            {
                PaintPathArrow(graphics, path.PathStep.HexsideEntry);
            }
            graphics.Pop();
        }
Example #3
0
        /// <summary>Paint the current shortese path.</summary>
        /// <param name="dc">Type: Graphics - Object representing the canvas being painted.</param>
        /// <param name="path">Type: <see cref="IDirectedPath"/> -
        /// A directed path (ie linked-list> of hexes to be painted.</param>
        protected virtual void PaintPath(DrawingContext graphics, IDirectedPathCollection path)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            var pen   = new Pen(Brushes.Black, 1.0F);
            var brush = new SolidColorBrush(Color.FromArgb(78, Colors.PaleGoldenrod.R, Colors.PaleGoldenrod.G, Colors.PaleGoldenrod.B));

            while (path != null)
            {
                var coords = path.PathStep.Hex.Coords;
                graphics.PushTransform(TranslateToHex(StartHex));
                graphics.DrawGeometry(brush, pen, HexgridPath);

                if (ShowPathArrow)
                {
                    PaintPathArrow(graphics, path);
                }

                path = path.PathSoFar;
            }
        }
Example #4
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 #5
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;
                }
            }
        }