void UpdateGridBrush()
        {
            if (map != null)
            {
                if (map.ShowGrid)
                {
                    double xSize  = map.CellSize.Width / map.Image.Width;
                    double ySize  = map.CellSize.Height / map.Image.Height;
                    double xStart = map.CellOrigin.X / map.Image.Width;
                    double yStart = map.CellOrigin.Y / map.Image.Height;

                    RectangleGeometry r = new RectangleGeometry(new Rect(0, 0, 100, 100));
                    Pen             p   = new Pen(new SolidColorBrush(map.GridColor), 1);
                    GeometryDrawing gd  = new GeometryDrawing(null, p, r);
                    DrawingBrush    db  = new DrawingBrush(gd);
                    db.TileMode = TileMode.Tile;
                    db.Viewport = new Rect(xStart, yStart, xSize, ySize);


                    MapGridCanvas.Background = db;
                    FogOfWar.InvalidateVisual();
                }
                else
                {
                    MapGridCanvas.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

                    FogOfWar.InvalidateVisual();
                }
            }
        }
        void UpdateGridBrush()
        {
            if (map != null)
            {
                if (map.ShowGrid)
                {
                    double xSize  = map.CellSize.Width / map.Image.Width;
                    double ySize  = map.CellSize.Height / map.Image.Height;
                    double xStart = map.CellOrigin.X / map.Image.Width;
                    double yStart = map.CellOrigin.Y / map.Image.Height;

                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Images/square.png")));
                    brush.TileMode = TileMode.Tile;
                    brush.Viewport = new Rect(xStart, yStart, xSize, ySize);

                    MapGridCanvas.Background = brush;
                    FogOfWar.InvalidateVisual();
                }
                else
                {
                    MapGridCanvas.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

                    FogOfWar.InvalidateVisual();
                }
            }
        }