private void LoadQuestion(int question) { this.ClearMistakes(); foreach (Label l in answersPanel.Children) { l.Content = String.Empty; } RoundData d = parent.round; Question q = d.normal[question]; questionLabel.Content = q.question; for (int i = 0; i < q.answers.Count; i++) { (answersPanel.Children[i] as Label).Content = String.Format("{0}", q.answers[i]); } this.question = q; parent.client.LoadQuestion(q); }
internal void LoadQuestion(Question q) { this.question = q; normalPage.ClearAnswers(q.answers.Count); }
public static RoundData Load(string path) { RoundData d = new RoundData(); XmlReaderSettings settings = new XmlReaderSettings { CloseInput = true, IgnoreComments = true }; XmlReader reader = XmlReader.Create(path, settings); // TODO: For the God's sake, could someone rewrite it so it's not the same things twice? DRY, man, DRY. reader.ReadToFollowing("NormalMode"); reader.ReadToDescendant("Question"); int i = 0; do { reader.MoveToAttribute("Title"); string questionString = reader.ReadContentAsString(); Question q = new Question(questionString); reader.MoveToElement(); reader.ReadToDescendant("Answer"); do { reader.MoveToAttribute("Points"); int points = reader.ReadContentAsInt(); reader.MoveToElement(); string answer = reader.ReadElementContentAsString(); q.AddAnswer(answer, points); } while (reader.ReadToNextSibling("Answer")); d.normal[i++] = q; } while (reader.ReadToNextSibling("Question")); reader.ReadToFollowing("FinalMode"); reader.ReadToDescendant("Question"); i = 0; do { reader.MoveToAttribute("Title"); string questionString = reader.ReadContentAsString(); Question q = new Question(questionString); reader.MoveToElement(); reader.ReadToDescendant("Answer"); do { reader.MoveToAttribute("Points"); int points = reader.ReadContentAsInt(); reader.MoveToElement(); string answer = reader.ReadElementContentAsString(); q.AddAnswer(answer, points); } while (reader.ReadToNextSibling("Answer")); d.final[i++] = q; } while (reader.ReadToNextSibling("Question")); return d; }