private void startAlgorithm(object sender, EventArgs e) { change_enabled_setting(); //Toggle controls AlgorithmManager.StartAlgorithm(); FormsHandler.LoadAndDisplayState(AlgorithmManager.GetCurrentState()); }
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 }
//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()); } }