Exemple #1
0
 public void AskQuestion()
 {
     WhatIAmAsking = qCollection.GetRandomQuestionAtLevel(Level);
     if (WhatIAmAsking != null)
     {
         GreenProgressBar();
         MyMain.label1.Content = Level.ToString() + " of 11";
         MyMain.richTextBox1.Document.Blocks.Clear();
         MyMain.richTextBox1.Document.Blocks.Add(new Paragraph(new Run(WhatIAmAsking.QuestionText)));
         MyMain.button1.IsEnabled = true;
         MyMain.button2.IsEnabled = true;
         MyMain.button3.IsEnabled = true;
         MyMain.button4.IsEnabled = true;
         MyMain.button5.IsEnabled = false;
         if (this.FiftyFifty == false) MyMain.button6.IsEnabled = true;
         else MyMain.button6.IsEnabled = false;
         if (this.MoreTime== false) MyMain.button7.IsEnabled = true;
         else MyMain.button7.IsEnabled = false;
         MyMain.button1.Content = WhatIAmAsking.AnswerA;
         MyMain.button2.Content = WhatIAmAsking.AnswerB;
         MyMain.button3.Content = WhatIAmAsking.AnswerC;
         MyMain.button4.Content = WhatIAmAsking.AnswerD;
         MyMain.progressBar1.Value = WhatIAmAsking.Time;
         timer.Start();
     }
     else
     {
         GameOver();
     }
 }
        // Loads the XML questions from this directory
        public bool LoadQuestions(string strDirectory, RichTextBox richMain)
        {
            if (Directory.Exists(strDirectory) == false)
            {
                System.Windows.MessageBox.Show("Couldn't find the directory containing questions: " + strDirectory, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }

            int intCount = 0;
            foreach(string strFile in Directory.EnumerateFiles(strDirectory,"*.xml")){

                XDocument thisXML = XDocument.Load(strFile);
                Question thisQuestion = new Question(strFile,richMain);
                lstQuestions.Add(thisQuestion);
                intCount++;
            }

            richMain.AppendText("Loaded a total of " + lstQuestions.Count() + " files" + Environment.NewLine);
            Count = lstQuestions.Count();

            return true;
        }