void RefreshControlBoxes() { if (cbTheme.Items.Count - 1 != QuestionDatabase.GetThemes().Length) { cbTheme.Items.Clear(); cbTheme.Items.AddRange(QuestionDatabase.GetThemes()); cbTheme.Items.Add("Neu..."); cbTheme.SelectedIndex = cbTheme.Items.Count == 1 ? -1 : 0; cbChapter.SelectedIndex = cbChapter.Items.Count <= 1 ? -1 : 0; } if (QuestionDatabase.ThemeExist(cbTheme.Text)) { if (cbChapter.Items.Count - 1 != QuestionDatabase.GetChapters(cbTheme.Text).Length || cbChapter.Items.Cast <string>().ToArray() != QuestionDatabase.GetChapters(cbTheme.Text)) { cbChapter.Items.Clear(); cbChapter.Items.AddRange(QuestionDatabase.GetChapters(cbTheme.Text)); cbChapter.Items.Add("Neu..."); cbChapter.SelectedIndex = cbChapter.Items.Count <= 1 ? -1 : 0; } } bDelChapter.Enabled = cbChapter.SelectedIndex != cbChapter.Items.Count - 1; bDelTheme.Enabled = cbTheme.SelectedIndex != cbTheme.Items.Count - 1; bAdd.Enabled = (cbTheme.SelectedIndex != cbTheme.Items.Count - 1 && cbTheme.SelectedIndex != -1) && (cbChapter.SelectedIndex != cbChapter.Items.Count - 1 && cbChapter.SelectedIndex != -1); }
private void ThemeBox_SelectionChangeCommitted(object sender, EventArgs e) { RefreshControlBoxes(); if (themeBox.SelectedIndex == themeBox.Items.Count - 1) { AddDialog a = new AddDialog( "Thema", (v, s) => { QuestionDatabase.AddTheme(v); OnAddFinish(s); }, (s) => !QuestionDatabase.ThemeExist(s) ); a.ShowDialog(); } else { RefreshControlBoxes(); } }
void RefreshControlBoxes() { if (themeBox.Items.Count - 1 != QuestionDatabase.GetThemes().Length) { themeBox.Items.Clear(); themeBox.Items.AddRange(QuestionDatabase.GetThemes()); themeBox.Items.Add("Neu..."); themeBox.SelectedIndex = themeBox.Items.Count == 1 ? -1 : 0; } if (QuestionDatabase.ThemeExist(themeBox.Text)) { if (checkedChapterList.Items.Count != QuestionDatabase.GetChapters(themeBox.Text).Length || checkedChapterList.Items.Cast <string>().ToArray() != QuestionDatabase.GetChapters(themeBox.Text)) { checkedChapterList.Items.Clear(); checkedChapterList.Items.AddRange(QuestionDatabase.GetChapters(themeBox.Text)); } } checkedChapterList.Enabled = themeBox.Items.Count != 0 || themeBox.SelectedIndex != themeBox.Items.Count - 1; bStartQuiz.Enabled = checkedChapterList.CheckedItems.Count != 0; }