Пример #1
0
        private void loadFile()
        {
            if (_questions.Count <= 0)
            {
                try
                {
                    DataSet questionSet = new DataSet();
                    questionSet.ReadXml(@"TriviaFiles\Trivia.xml");

                    int index = 0;

                    foreach (DataRow row in questionSet.Tables[0].Rows)
                    {
                        Question_Key key = new Question_Key();
                        key.QuestionText = row["QuestionString"].ToString();
                        key.AnswerA = row["AnswerA"].ToString();
                        key.AnswerB = row["AnswerB"].ToString();
                        key.AnswerC = row["AnswerC"].ToString();
                        key.AnswerD = row["AnswerD"].ToString();
                        key.Correct = (Answer_Key)Enum.Parse(typeof(Answer_Key), row["Correct"].ToString());

                        _questions.Add(index, key);
                        index++;
                    }

                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #2
0
        public void OnQuestionLoad(int questionIndex, Question_Key questionItem)
        {
            try
            {
                // Dim question text
                //questionLabel.Opacity = 1;
                 this.Dispatcher.Invoke((Action)(() =>
                {
                // Clear stored answer and save question object
                CurrentAnswer = Answer_Key.None;
                CurrentQuestion = questionItem;

                // Load question text
                questionLabel.Content = CurrentQuestion.QuestionText;
                //QuestionCount = 10;
                questionCounter.Content = "Question: ";
                // private const string GAME_START = "Game Started, {0} questions.";

                // Prep answer buttons
                SetAnswerButton(A, true, CurrentQuestion.AnswerA);
                SetAnswerButton(B, true, CurrentQuestion.AnswerB);
                SetAnswerButton(C, true, CurrentQuestion.AnswerC);
                SetAnswerButton(D, true, CurrentQuestion.AnswerD);
                }));
            }
            catch( Exception ex)
            {
                string x = ex.Message;
                throw ex;
            }
        }