Exemple #1
0
        public void RedrawPartyLocation()
        {
            MapBox mapBox = _drawingUi.GetMapBox();

            if (mapBox.Width > 0 && mapBox.Height > 0)
            {
                Bitmap map = new Bitmap(mapBox.Width, mapBox.Height);

                using (Graphics graphics = Graphics.FromImage(map))
                {
                    graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                    if (_partyLocation != null)
                    {
                        Point positionOnScreen       = PositionManager.HexToScreen(_partyLocation, mapBox.TopLeftCoordinate);
                        var   pictureLocationAndSize = new Rectangle(positionOnScreen, new Size(50, 44));

                        using (var selectImage = Image.FromFile("Images/PartyIndicator.png"))
                        {
                            graphics.DrawImage(selectImage, pictureLocationAndSize);
                        }
                    }
                }

                mapBox.UpdateLayerAndMap(Layer.PartyLocation, map);
            }
        }
        private void DrawMapAsynchronously(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            MapBox mapBox = _drawingUi.GetMapBox();

            var alphaList = GetAllAlphaValues();

            for (int i = 0; i < _layerDrawers.Count; i++)
            {
                var layerDrawer = _layerDrawers[i];
                if (alphaList[i] == 0)
                {
                    mapBox.UpdateLayer(layerDrawer.GetLayerType(), null);
                }
                else
                {
                    var layerImage = layerDrawer.MakeLocalMap(_handlerTag, alphaList[i]);
                    if (layerImage != null)
                    {
                        mapBox.UpdateLayer(layerDrawer.GetLayerType(), layerImage);
                    }
                }
            }
            _partyLayerDrawer.RedrawPartyLocation();
            mapBox.UpdateLayer(Layer.OverlayGrid, _overlayGridLayerDrawer.DrawOverlay());

            mapBox.RedrawMap();
        }
Exemple #3
0
        public Image MakeLocalMap(string handlerTag, int alpha, bool useCache = true)
        {
            var hexes = Db.Hexes.GetArea(handlerTag, UiInterface.GetMapBox().MapArea, useCache);

            return(MakeMapFromEntireArea(hexes, alpha));
        }
        public Image DrawOverlay()
        {
            MapBox mapBox = _drawingUi.GetMapBox();

            Bitmap image = null;

            if (mapBox.Width > 0 && mapBox.Height > 0)
            {
                image = new Bitmap(mapBox.Width, mapBox.Height);

                //If there should be no grid, we return an empty image
                if (_drawingUi.GetOverlayGridAlpha() == 0)
                {
                    return(image);
                }

                Image overlayImage = Image.FromFile("Images/drawingguide.png");

                using (var graphics = Graphics.FromImage(image))
                {
                    graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                    int col = (int)((mapBox.TopLeftCoordinate.X / 3) % 2);

                    HexCoordinate tlCoordinate = mapBox.TopLeftCoordinate;
                    int           x;
                    if (tlCoordinate.X >= 0)
                    {
                        x = 37 - 37 * (int)Math.Abs(tlCoordinate.X % 6);
                    }
                    else
                    {
                        x = 37 - 37 * (int)Math.Abs(6 + (tlCoordinate.X % 6));
                    }

                    int y;
                    if (tlCoordinate.Y >= 0)
                    {
                        y = 22 - 44 * (int)Math.Abs(tlCoordinate.Y % 3) - col * 66;
                    }
                    else
                    {
                        y = 22 - 44 * (int)Math.Abs(3 + tlCoordinate.Y % 3) - col * 66;
                    }


                    if (x > 0)
                    {
                        x -= 111;
                        y -= 66;
                    }

                    if (y > 0)
                    {
                        y -= 132;
                    }
                    else if (y < 132)
                    {
                        y += 132;
                    }

                    int staticY = y;

                    while (x < mapBox.Width)
                    {
                        while (y < mapBox.Height)
                        {
                            var pictureLocationAndSize = new Rectangle(x, y, 112, 132);
                            graphics.DrawImage(overlayImage, pictureLocationAndSize);

                            y += 132;
                        }
                        x   += 111;
                        col += 1;
                        if (col % 2 == 0)
                        {
                            y = staticY;
                        }
                        else
                        {
                            y = staticY - 66;
                        }
                    }
                }
            }

            return(image);
        }