示例#1
0
        private void NextQuestion()
        {
            lblGamePoints.Content = points.ToString();
            //Make a Button list with the results and shuffle the list, than create buttons
            List <Button> resultList = new List <Button>();
            rQuestion     q          = currentGame.getQuestion();

            if (q != null)
            {
                currentQuestion     = q;
                lblQuestion.Content = q.questionText;
                foreach (KeyValuePair <string, string> item in q.resultList)
                {
                    Button tmpResults = new Button();
                    tmpResults.Content = item.Value;
                    tmpResults.Name    = item.Key;
                    tmpResults.Click  += new RoutedEventHandler(Click_CheckResult);
                    resultList.Add(tmpResults);
                    Shuffle(resultList);
                }
                foreach (Button b in resultList)
                {
                    spResults.Children.Add(b);
                }
            }
            else
            {
                //All Questions asked, reset all
                MessageBox.Show("Alle Fragen richtig beantwortet");
                resetWatch();
                currentGame.ExitGame();
                mainWindow.ToFinishGame(points);
                resetPoints();
            }
        }
示例#2
0
 private void BtnAddQuestion_Click(object sender, RoutedEventArgs e)
 {
     //if the Question is already in the database,
     //dont add the question again
     if (rQuestion.IsQuestionInDB(tbxQueestion.Text))
     {
         MessageBox.Show("Frage ist bereits vorhanden");
     }
     else
     {
         Dictionary <string, string> results = new Dictionary <string, string>();
         results.Add("resultTrue", tbxResultOne.Text);
         results.Add("resultOne", tbxResultTwo.Text);
         results.Add("resultTwo", tbxResultThree.Text);
         results.Add("resultThree", tbxResultFour.Text);
         rQuestion newQuestion = new rQuestion(tbxQueestion.Text, results);
         newQuestion.AddQuestion();
         MessageBox.Show("Frage hinzugefügt");
     }
 }