Пример #1
0
        private void startAlgorithm(object sender, EventArgs e)
        {
            change_enabled_setting(); //Toggle controls
            AlgorithmManager.StartAlgorithm();

            FormsHandler.LoadAndDisplayState(AlgorithmManager.GetCurrentState());
        }
Пример #2
0
 private void comboboxQmatrixselect_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!FormsHandler.lock_indexChange_events && ((ComboBox)sender).SelectedIndex > -1)
     {
         FormsHandler.large_dropdownChanged();
     }
 }
Пример #3
0
        private void restartAlgorithm_buttonClick(object sender, EventArgs e)
        {
            FormsHandler.loadedState = AlgorithmManager.GetCurrentState();
            AlgorithmManager.EraseBoard();

            FormsHandler.ResetConfiguration(); //Clear comboboxes and other forms
            change_enabled_setting();          //Togle controls
        }
Пример #4
0
        //Advance algorithm button
        async private void buttonAdvancestepsdropdownClick(object sender, EventArgs e)
        {
            FormsHandler.halted = false;
            int stepsToTake = Int32.Parse(comboboxAdvancesteps.Text);
            int episodes    = Int32.Parse(comboboxAdvanceepisodes.Text);

            if (episodes > 0)
            {
                stepsToTake += (Int32.Parse(comboboxAdvanceepisodes.Text) * FormsHandler.loadedState.GetStepLimit()) + 1; //+1 to get the new episode generated
            }
            int initial_delay = Int32.Parse(comboboxDelayms.Text);
            int delay         = initial_delay;

            if (checkBox1.Checked)
            {
                FormsHandler.hasUrlStartedChasing = true;
            }

            if (FormsHandler.hasUrlStartedChasing)
            {
                while (FormsHandler.hasUrlStartedChasing)
                {
                    AlgorithmManager.StepPrepare();
                }
                FormsHandler.LoadAndDisplayState(AlgorithmManager.GetCurrentState());
            }


            else if (stepsToTake > 1)
            {
                textboxProgresssteps.Text         = stepsToTake.ToString();
                groupboxCountdown.Enabled         = true;
                groupboxAlgorithmprogress.Enabled = false;
                groupboxHistory.Enabled           = false;
                while (stepsToTake-- > 0 && !FormsHandler.halted)
                {
                    AlgorithmManager.StepPrepare();
                    FormsHandler.LoadAndDisplayState(AlgorithmManager.GetCurrentState());
                    textboxProgresssteps.Text = stepsToTake.ToString();
                    do
                    {
                        await Task.Delay(1);

                        textboxCountdown.Text = delay.ToString();
                    } while (--delay > 0 && !FormsHandler.halted);
                    delay = initial_delay;
                }
                groupboxAlgorithmprogress.Enabled = true;
                groupboxCountdown.Enabled         = false;
                groupboxHistory.Enabled           = true;
            }

            else
            {
                AlgorithmManager.StepPrepare();
                FormsHandler.LoadAndDisplayState(AlgorithmManager.GetCurrentState());
            }
        }
Пример #5
0
 private void qmatrix_small_dropdownChanged(object sender, EventArgs e)
 {
     if (!FormsHandler.lock_indexChange_events && ((ComboBox)sender).SelectedIndex > -1)
     {
         if (((ComboBox)sender).SelectedText != "None.")
         {
             FormsHandler.small_dropdownChanged((ComboBox)sender);
         }
     }
 }
Пример #6
0
        private void button6Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxEmptysquare.Text, out double result);

            if (!success)
            {
                comboboxEmptysquare.Text = "Invalid.";
            }
            else
            {
                MoveResult.list[MoveResult.CanMissing] = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
Пример #7
0
        private void button1Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxMovedwithoutwall.Text, out double result);

            if (!success)
            {
                comboboxMovedwithoutwall.Text = "Invalid.";
            }
            else
            {
                MoveResult.list[MoveResult.TravelSucceeded] = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
Пример #8
0
        private void button2Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxE.Text, out double result);

            if (!success)
            {
                comboboxE.Text = "Invalid.";
            }
            else
            {
                FormsHandler.loadedState.liveQmatrix.e = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
Пример #9
0
        private void set_stepsFrom_dropdown(object sender, EventArgs e)
        {
            bool success = Int32.TryParse(comboboxSteps.Text, out int result);

            if (!success)
            {
                comboboxSteps.Text = "Invalid.";
            }
            else
            {
                Qmatrix.stepLimit = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
Пример #10
0
 private void comboboxHistorystep_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         bool success = Int32.TryParse(comboboxHistorystep.Text, out int result);
         if (!success || result < 1 || result > comboboxHistorystep.Items.Count)
         {
             comboboxHistorystep.Text = "Invalid.";
         }
         else
         {
             comboboxHistorystep.SelectedIndex = result;
             FormsHandler.LoadAndDisplayState((AlgorithmState)comboboxHistorystep.SelectedItem);
         }
     }
 }
Пример #11
0
        private void history_indexChanged(object sender, EventArgs e)
        {
            ComboBox sender_box = (ComboBox)sender;

            if (sender_box.SelectedIndex > -1)
            {
                comboboxHistorystep.Items.Clear();

                AlgorithmEpisode to_display = (AlgorithmEpisode)sender_box.SelectedItem;
                comboboxHistorystep.Items.AddRange(to_display.stateHistoryData.ToArray());
                comboboxHistorystep.SelectedIndex = 0;

                AlgorithmState stateTo_display = (AlgorithmState)comboboxHistorystep.Items[0];
                FormsHandler.LoadAndDisplayState(stateTo_display);
            }
        }
Пример #12
0
        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.
        }
Пример #13
0
        private void comboboxHistorystep_SelectedIndexChanged(object sender, EventArgs e)
        {
            AlgorithmState stateTo_dislay = (AlgorithmState)((ComboBox)sender).SelectedItem;

            FormsHandler.LoadAndDisplayState(stateTo_dislay);
        }
Пример #14
0
 private void resetConfig_buttonClick(object sender, EventArgs e)
 {
     FormsHandler.ResetConfiguration();
 }