public QuestionView()
 {
     InitializeComponent();
     defaultAnswerButtonBrush = new Button().Background;
     maxCountDown = TimeSpan.FromSeconds(30);
     countDown = new DispatcherTimer();
     countDown.Interval = TimeSpan.FromSeconds(1);
     countDown.Tick += ((o, args) =>
         {
             remainingCountDown = remainingCountDown.Subtract(TimeSpan.FromSeconds(1));
             Timer.Content = remainingCountDown.Seconds;
             if (remainingCountDown == TimeSpan.Zero)
             {
                 countDown.Stop();
                 Timer.Content = "Time's Up";
             }
         });
     DataContextChanged += (
         (o, e) => 
             {
                 viewModel = e.NewValue as Question;
                 A.Background = defaultAnswerButtonBrush;
                 B.Background = defaultAnswerButtonBrush;
                 C.Background = defaultAnswerButtonBrush;
                 D.Background = defaultAnswerButtonBrush;
             });
     questionEnterAnimation = (Storyboard)Resources["QuestionEnterAnimation"];
     questionLeaveAnimation = (Storyboard)Resources["QuestionLeaveAnimation"];
 }
Exemple #2
0
 public void LoadQuestionsToSerialiser()
 {
     List<Question> QuestionList = new List<Question>();
     TextReader reader = new StreamReader(ConfigurationManager.AppSettings["XmlQuestionsText"]);
     String line;
     try
     {
         while ((line = reader.ReadLine()) != null)
         {
             Question ques = new Question();
             ques.QuestionContent = line;
             ques.A = reader.ReadLine();
             ques.B = reader.ReadLine();
             ques.C = reader.ReadLine();
             ques.D = reader.ReadLine();
             ques.CorrectAnswer = reader.ReadLine();
             //line = reader.ReadLine();
             //ques.Category = QuestionCategory.Gray; (QuestionCategory)Enum.Parse(typeof(QuestionCategory), line);
             line = reader.ReadLine();
             ques.Difficulty = (QuestionDifficulty)Enum.Parse(typeof(QuestionDifficulty), line);
             QuestionList.Add(ques);
         }
     }
     catch { }
     reader.Close();
     SerialiseToXML(QuestionList);
 }