private void applyButton_Click(object sender, EventArgs e) { if (entry != null) { entry.SetText(textBox.Text); entry.SetOpen(isOpenCheckbox.Checked); if (practiceButton.Checked == true) { (entry as Content.Challenge).SetChallengeType((Content.Challenge.Type)typeBox.SelectedIndex); (entry as Content.Challenge).SetAnswers(new List <string>(answersBox.Text.Split('\n'))); } if (section.GetTopics()[topicBox.SelectedIndex] != topic) { editor.content.TransferEntry(topic, section.GetTopics()[topicBox.SelectedIndex], entry); } } else { if (theoryButton.Checked == true) { editor.content.AddTheory(topic, textBox.Text, isOpenCheckbox.Checked); } else { List <string> answers = new List <string>(answersBox.Text.Split('\n')); editor.content.AddChallenge(topic, textBox.Text, isOpenCheckbox.Checked, (Content.Challenge.Type)typeBox.SelectedIndex, answers); } } editor.RefreshGrid(); Dispose(); }
public EntryEditor(Editor editor, Content.Section section, Content.Topic topic, Content.Entry entry) { InitializeComponent(); this.editor = editor; this.section = section; this.topic = topic; this.entry = entry; textBox.Text = entry.GetText(); isOpenCheckbox.Checked = entry.IsOpen(); if (entry is Content.Challenge) { typeBox.SelectedIndex = (int)(entry as Content.Challenge).GetChallengeType(); foreach (string str in (entry as Content.Challenge).GetAnswers()) { answersBox.Text += str + "\n"; } practiceButton.Checked = true; } int selection = 0; foreach (Content.Topic item in section.GetTopics()) { topicBox.Items.Add(item.GetTitle()); if (item == topic) { selection = topicBox.Items.Count - 1; } } topicBox.SelectedIndex = selection; displayControls(); }