/// <inheritdoc/>
        public virtual void PaintMap(Graphics g)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

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

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

            PaintForEachHex(g, clipHexes, coords => {
                this[coords].Paint(g);
                if (ShowHexgrid)
                {
                    g.DrawPath(Pens.Black, HexgridPath);
                }
                if (LandmarkToShow > 0)
                {
                    g.DrawString(LandmarkDistance(coords, LandmarkToShow - 1), font, brush, textOffset);
                }
            });
            g.EndContainer(container);
        }
Beispiel #2
0
        /// <inheritdoc/>
        public virtual void PaintMap(DrawingContext graphics)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

//      dc.InterpolationMode = InterpolationMode.HighQualityBicubic;
            var clipHexes = GetClipInHexes(HexPoint.Empty.ToWpfPoint(), MapSizeHexes.ToWpfSize());

            var fontSize   = SystemFonts.MenuFontSize * 0.8F;
            var brush      = Brushes.Black;
            var textOffset = new HexPoint(GridSize.Scale(0.50F).ToSize()).ToWpfPoint()
                             - new Vector(fontSize, fontSize);

            PaintForEachHex(graphics, clipHexes, coords => {
                this[coords].Paint(graphics);
                if (ShowHexgrid)
                {
                    graphics.DrawGeometry(Brushes.Transparent, new Pen(Brushes.Black, 1), HexgridPath);
                }
                if (LandmarkToShow > 0)
                {
                    graphics.DrawText(new FormattedText(
                                          LandmarkDistance(coords, LandmarkToShow - 1),
                                          CultureInfo.GetCultureInfo("en-US"),
                                          FlowDirection.LeftToRight,
                                          new Typeface("Verdana"),
                                          fontSize,
                                          Brushes.Black),
                                      textOffset);
                }
            });
            graphics.Pop();
        }
Beispiel #3
0
        /// <inheritdoc/>>
        /// <param name="g">Graphics object for the canvas being painted.</param>
        public virtual void PaintHighlight(Graphics g)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }
            var container = g.BeginContainer();

            TranslateGraphicsToHex(g, StartHex);
            g.DrawPath(Pens.Red, HexgridPath);

            g.EndContainer(container); container = g.BeginContainer();
            PaintPath(g, Path);

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

            g.EndContainer(container); container = g.BeginContainer();
            var clipHexes = GetClipInHexes(g.VisibleClipBounds);

            using (var shadeBrush = new SolidBrush(Color.FromArgb(ShadeBrushAlpha, ShadeBrushColor))) {
                PaintForEachHex(g, clipHexes, coords => {
                    if (ShowFov && Fov != null && !Fov[coords])
                    {
                        g.FillPath(shadeBrush, HexgridPath);
                    }

                    if (LandmarkToShow != -1)
                    {
                        var font       = SystemFonts.MenuFont;
                        var brush      = Brushes.Black;
                        var textOffset = new Point(GridSize.Scale(0.50F).ToSize()
                                                   - new SizeF(font.Size, font.Size).Scale(0.8F).ToSize());
                        g.DrawString(LandmarkText(coords, LandmarkToShow), font, brush, textOffset);
                    }
                });
            }
        }