public BoardDisplay() : base() { SquareBoardDisplay.setBackgrounds(); //This initializes a dictionary of "boardVisistedState" - background image pairs. //Initialize 10x10 grid for (int i = 0; i < InitialSettings.SizeOfBoard; i++) { for (int j = 0; j < InitialSettings.SizeOfBoard; j++) { boardData[i].Add(new SquareBoardDisplay(i, j)); } } }
private void Form1Load(object sender, EventArgs e) { AlgorithmManager.SetDefaultConfiguration(); //Second entry point of the program. //When the form loads, we'll create some pictureboxes, that will function as the robot world grid. FormsHandler.load(); PictureBox picturebox_inProgress; //Temporary picturebox SquareBoardDisplay squareTo_build; //This is object inherits from boardSquare, but has a picture element. //Create pictureboxes and pass them to our board for (int i = 0; i < InitialSettings.SizeOfBoard; i++) { for (int j = 0; j < InitialSettings.SizeOfBoard; j++) { //Fill in the column with rows picturebox_inProgress = new PictureBox(); squareTo_build = new SquareBoardDisplay(i, j); picturebox_inProgress.Name = i.ToString() + "-" + j.ToString(); //Each name is the coordinate picturebox_inProgress.Location = new Point(InitialSettings.X_Offset + (i * InitialSettings.EdgeLength), InitialSettings.Y_Offset + (j * InitialSettings.EdgeLength)); picturebox_inProgress.Size = new Size(InitialSettings.EdgeLength, InitialSettings.EdgeLength); picturebox_inProgress.SizeMode = PictureBoxSizeMode.StretchImage; picturebox_inProgress.BackgroundImageLayout = ImageLayout.Stretch; Controls.Add(picturebox_inProgress); squareTo_build.pictureData = picturebox_inProgress; FormsHandler.Add(i, 9 - j, squareTo_build); //9-j to handle the board layout, for some reason! } } //Called from the restart button, but works here on initial launch. //This triggers the constructor for algorithm manager, as well textboxStatus.Text = "Program launched."; FormsHandler.DisplayState(); //First time we display the board. }
//Triggers the constructor. Adds a PictureBox to a PictureSquare. static public void Add(int i, int j, SquareBoardDisplay squareTo_set) { picture_board.boardData[i][j] = squareTo_set; }