private void startButton_Click(object sender, EventArgs e) { // turn start button blue cuz it looks good startButton.ForeColor = System.Drawing.Color.Cyan; // find out which categories were selected List <string> checkedItemsList = new List <string>(); for (int i = 0; i <= (genreCheckedListBox.Items.Count - 1); i++) { if (genreCheckedListBox.GetItemChecked(i)) { checkedItemsList.Add(genreCheckedListBox.Items[i].ToString()); } } // if user did not select a category, warn them and exit. if (checkedItemsList.Count < 1) { MessageBox.Show("Please select a category!"); return; } // otherwise, generate a prompt to match BasicTextPromptForm prompt = new BasicTextPromptForm(); prompt.categories = checkedItemsList; PromptGenerator promptGenerator = new PromptGenerator(checkedItemsList); BasicTextPrompt newPrompt; if (speedModeBox.Checked) { //promptGenerator.generatePrompt(Constants.speedModeTimeLimit); prompt.speedModeLimit = Constants.speedModeTimeLimit; newPrompt = promptGenerator.findAPrompt(checkedItemsList, Constants.speedModeTimeLimit); } else { //promptGenerator.generatePrompt(Constants.speedModeOff); prompt.speedModeLimit = 0; newPrompt = promptGenerator.findAPrompt(checkedItemsList, 0); } if (newPrompt.ERROR == true) { Console.WriteLine("BasicTextPromptForm.generateNewPrompt() : Error - failed to make new prompt"); MessageBox.Show("Error generating prompt. Please try again."); return; } //FancyTextPromptForm promptTest = new FancyTextPromptForm(); prompt.InitializePrompt(newPrompt); prompt.ShowDialog(); }
// generate a new prompt without destroying or reloading form private void generateNewPrompt() { PromptGenerator generator = new PromptGenerator(categories); BasicTextPrompt newPrompt = generator.findAPrompt(categories, speedModeLimit); if (newPrompt.ERROR == true) { Console.WriteLine("BasicTextPromptForm.generateNewPrompt() : Error - failed to make new prompt"); MessageBox.Show("Error generating prompt. Please try again."); return; } InitializePrompt(newPrompt); }