Exemple #1
0
        private void startAlgorithm(object sender, EventArgs e)
        {
            change_enabled_setting(); //Toggle controls
            AlgorithmManager.StartAlgorithm();

            FormsHandler.LoadAndDisplayState(AlgorithmManager.GetCurrentState());
        }
Exemple #2
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());
            }
        }
Exemple #3
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);
         }
     }
 }
Exemple #4
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);
            }
        }
Exemple #5
0
        private void comboboxHistorystep_SelectedIndexChanged(object sender, EventArgs e)
        {
            AlgorithmState stateTo_dislay = (AlgorithmState)((ComboBox)sender).SelectedItem;

            FormsHandler.LoadAndDisplayState(stateTo_dislay);
        }