/// <summary> /// Fire QuestionSelected event /// </summary> /// <param name="qb">QuestionButton selected</param> private void SelectQuestion(QuestionButton qb) { EventHandler <QuestionButtonEventArgs> handler = QuestionSelected; if (handler != null) { handler(null, new QuestionButtonEventArgs(qb)); } }
public void InitializeButtons() { categories = new CategoryButton[] { categoryButton1, categoryButton2, categoryButton3, categoryButton4, categoryButton5 }; questions = new QuestionButton[] { questionButton1A, questionButton1B, questionButton1C, questionButton1D, questionButton1E, questionButton2A, questionButton2B, questionButton2C, questionButton2D, questionButton2E, questionButton3A, questionButton3B, questionButton3C, questionButton3D, questionButton3E, questionButton4A, questionButton4B, questionButton4C, questionButton4D, questionButton4E, questionButton5A, questionButton5B, questionButton5C, questionButton5D, questionButton5E }; tieBreaker = new QuestionButton(); try { XmlReader input = XmlReader.Create("config.xml"); // 5 categories and 5 questions in each category, 30 buttons total for (int category = 0; category < 5; category++) { while (!input.IsStartElement("name")) { input.Read(); } categories[category].Text = input.ReadString(); for (int question = 0; question < 5; question++) { int index = (category * 5) + question; while (!input.IsStartElement("name")) { input.Read(); } questions[index].Question = input.ReadString(); while (!input.IsStartElement("answer")) { input.Read(); } questions[index].Answer = input.ReadString(); questions[index].Points = (question + 1) * 10; } } while (!input.IsStartElement("name")) { input.Read(); } tieBreaker.Question = input.ReadString(); while (!input.IsStartElement("answer")) { input.Read(); } tieBreaker.Answer = input.ReadString(); tieBreaker.Points = 50; input.Close(); } catch (Exception e) { MessageBox.Show("Could not open config.xml: " + e.ToString()); Environment.Exit(0); } }
/// <summary> /// Constructor /// </summary> /// <param name="button">QuestionButton that was selected by player</param> public QuestionButtonEventArgs(QuestionButton button) { qb = button; }