Exemple #1
0
        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);
        }
Exemple #2
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            Question b = null;

            try {
                switch (tType.SelectedIndex)
                {
                case (0):
                    b = FeedTextInput();
                    break;

                case (1):
                    b = FeedABCDInput();
                    break;

                default:
                    throw new NotImplementedException();
                }
            }catch (EvaluateException er) {
                Error(er.Message);
                return;
            }

            QuestionDatabase.AddQuestion(cbTheme.Text, cbChapter.Text, b);

            ClearInput();
        }
Exemple #3
0
        private void cbChapter_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (cbChapter.SelectedIndex == cbChapter.Items.Count - 1)
            {
                AddDialog a = new AddDialog(
                    "Kapitel",
                    (v, s) => { QuestionDatabase.AddChapter(cbTheme.Text, v); OnAddFinish(s); },
                    (s) => !QuestionDatabase.ChapterExist(cbTheme.Text, s)
                    );

                a.ShowDialog();
            }
            else
            {
                bDelChapter.Enabled = cbChapter.SelectedIndex != cbChapter.Items.Count - 1;
            }
        }
Exemple #4
0
        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();
            }
        }
Exemple #5
0
        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;
        }
Exemple #6
0
 private void bClearDatabase_Click(object sender, EventArgs e)
 {
     QuestionDatabase.Clear();
 }