コード例 #1
0
ファイル: Form1.cs プロジェクト: NelsonG6/BenderWorld
        private void Form1_Load(object sender, EventArgs e)
        {
            AlgorithmState.SetDefaultConfiguration();


            //Second entry point of the program.
            //When the form loads, we'll create some pictureboxes, that will function as the robot world grid.


            PictureBox    picturebox_in_progress; //Temporary picturebox
            PictureSquare square_to_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 < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    //Fill in the column with rows
                    picturebox_in_progress          = new PictureBox();
                    square_to_build                 = new PictureSquare();
                    picturebox_in_progress.Name     = i.ToString() + "-" + j.ToString(); //Each name is the coordinate
                    picturebox_in_progress.Location =
                        new Point(InitialSettings.x_offset() + (i * InitialSettings.edge_length()),
                                  InitialSettings.y_offset() + (j * InitialSettings.edge_length()));
                    picturebox_in_progress.Size     = new Size(InitialSettings.edge_length(), InitialSettings.edge_length());
                    picturebox_in_progress.SizeMode = PictureBoxSizeMode.StretchImage;
                    picturebox_in_progress.BackgroundImageLayout = ImageLayout.Stretch;
                    Controls.Add(picturebox_in_progress);
                    square_to_build.pictureData = picturebox_in_progress;
                    FormsHandler.Add(i, 9 - j, square_to_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.
        }