private void MapForm_Load(object sender, EventArgs e)
        {
            //Run the load function
            get_tiles("roomicons.png", tiles_list);
            //Load a Palletized version of these tiles so we can switch between them.
            get_tiles("PalletizedRoomIcons.png", PalletizedTiles);

            //MapFormLoad(sender, e);
            tmap = new TileMap(new Vector2 <int, int>(15, 15));
            TileGraphic[,] tmap_ = new TileGraphic[32, 32];
            tmap.map             = tmap_;
            MapFormLoad(sender, e);

            //Adding the random start point.
            Random Maprandomizer = new Random();
            int    startx        = Maprandomizer.Next(0, 15);
            int    starty        = Maprandomizer.Next(0, 15);

            int endx = Maprandomizer.Next(0, 15);
            int endy = Maprandomizer.Next(0, 15);

            //Set the finish room
            mazemap.SetFinishRoom(endx, endy);
            //Make the map and finish making it.
            mazemap.SetStartRoom(startx, starty);
            make_map(new Vector2 <int, int>(startx, starty), new Vector2 <int, int>(endx, endy), 250);
            //make_map(new Vector2<int, int>(5, 5), new Vector2<int, int>(6, 6), 25);
        }
        //parameter TilesList is different from local tileslist
        public void get_tiles(string directory, List <TileGraphic> TilesList)
        {
            int tileWidth  = 64;
            int tileHeight = 64;
            int tileRows   = 10;
            int tileCols   = 10;

            using (Bitmap sourceBmp = new Bitmap(directory))
            {
                Size      s        = new Size(tileWidth, tileHeight);
                Rectangle destRect = new Rectangle(Point.Empty, s);
                for (int y = 0; y < tileRows; y++)
                {
                    for (int x = 0; x < tileCols; x++)
                    {
                        Point     loc     = new Point(tileWidth * x, tileHeight * y);
                        Rectangle srcRect = new Rectangle(loc, s);
                        Bitmap    tile    = new Bitmap(tileWidth, tileHeight);
                        Graphics  G       = Graphics.FromImage(tile);
                        G.DrawImage(sourceBmp, destRect, srcRect, GraphicsUnit.Pixel);
                        TileGraphic t = new TileGraphic();
                        t.localtile = tile;  //Set the graphic in the local tile
                        t.name      = String.Format("{0:00}", "{1:00}", x, y);
                        TilesList.Add(t);
                    }
                }
            }
        }
        //Map form Load Class taken from StackOverFlow
        // here: https://stackoverflow.com/questions/23786295/basic-tile-map-in-winforms
        private void MapFormLoad(object sender, EventArgs e)
        {
            int tileWidth  = 64;
            int tileHeight = 64;
            int tileRows   = 15;
            int tileCols   = 15;


            using (Bitmap sourceBmp = new Bitmap("roomicons.png"))
            {
                Size      s         = new Size(tileWidth, tileHeight);
                Rectangle destRect  = new Rectangle(Point.Empty, s);
                int       tempindex = 0;
                for (int row = 0; row < tileRows; row++)
                {
                    for (int col = 0; col < tileCols; col++)
                    {
                        PictureBox p = new PictureBox();
                        p.Size     = s;
                        p.SizeMode = PictureBoxSizeMode.CenterImage;
                        Point loc = new Point((tileWidth * col) + ((col * 2) - 1), (tileHeight * row) + ((row * 2) - 1));
                        //Rectangle srcRect = new Rectangle(loc, s);
                        //Bitmap tile = new Bitmap(tileWidth, tileHeight);
                        // Graphics G = Graphics.FromImage(tile);
                        // G.DrawImage(sourceBmp, destRect, srcRect, GraphicsUnit.Pixel);

                        //tempindex++;
                        //if (tempindex > tiles_list.Count - 1) { tempindex = tiles_list.Count - 1; }
                        // Bitmap temp_bmp = tiles_list.ToArray()[tempindex].localtile;
                        Bitmap temp_bmp = tiles_list.ToArray()[0].localtile;

                        p.Image    = temp_bmp;
                        p.Location = loc;
                        p.Tag      = loc;
                        p.Name     = col + "," + row;
                        p.Click   += this.onclick_;
                        TileGraphic tempgraphic = new TileGraphic();
                        tempgraphic.localtile       = temp_bmp;
                        tmap.map[col, row]          = tempgraphic;
                        tmap.map[col, row].name     = new string(String.Format(col + "," + row).ToCharArray());
                        tmap.map[col, row].TileType = 0;

                        // p.MouseDown += p_MouseDown;
                        // p.MouseUp += p_MouseUp;
                        // p.MouseMove += p_MouseMove;
                        this.Controls.Add(p);
                    }
                }
            }

            //MapForm_Load(sender, e);
        }
 public TileMap(Vector2 <int, int> size)
 {
     width              = size.X;
     height             = size.Y;
     TileGraphic[,] map = new TileGraphic[width, height];
 }