private void LoadPreviousQuestion() { DeleteQuestionCommand.RaiseCanExecuteChanged(); if (SelectedQuestion != 1) { SelectedQuestion--; SelectedPicture = Pictures[SelectedQuestion - 1]; QuestionText = QuestionsAnswers[SelectedQuestion - 1].Question; Alternative1Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeOne; Alternative2Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeTwo; Alternative3Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeThree; var CA = QuestionsAnswers[SelectedQuestion - 1].Answer; if (CA == Alternative1Text) { Alt1Correct = true; Alt2Correct = false; Alt3Correct = false; } else if (CA == Alternative2Text) { Alt2Correct = true; Alt1Correct = false; Alt3Correct = false; } else { Alt3Correct = true; Alt1Correct = false; Alt2Correct = false; } } DeleteQuestionCommand.RaiseCanExecuteChanged(); }
private void initializeApplication() { Pictures = new List <BitmapImage>(); Pictures.Add(new BitmapImage()); QuestionsAnswers = new List <QuestionData>(); QuestionsAnswers.Add(new QuestionData()); SelectedPicture = null; BackgroundPicture = null; SelectedQuestion = 1; QuestionText = ""; Alternative1Text = ""; Alternative2Text = ""; Alternative3Text = ""; Alt1Correct = false; Alt2Correct = false; Alt3Correct = false; DeleteQuestionCommand.RaiseCanExecuteChanged(); HeaderText = "Här kan du skriva vilken rubrik du vill ha."; }
private void LoadNextQuestion() { if (SelectedPicture == null || SelectedPicture.UriSource == null) { MessageBox.Show("Du måste välja en bild till frågan!"); return; } if (string.IsNullOrEmpty(QuestionText)) { MessageBox.Show("Du måste skriva en fråga!"); return; } if (string.IsNullOrEmpty(Alternative1Text) || string.IsNullOrEmpty(Alternative2Text) || string.IsNullOrEmpty(Alternative3Text)) { MessageBox.Show("Du måste skriva alla 3 svars alternativ!"); return; } if (Alt1Correct == false && Alt2Correct == false && Alt3Correct == false) { MessageBox.Show("Du måste välja vad som är rätt svar!"); return; } SelectedQuestion++; if (QuestionsAnswers.Count < SelectedQuestion) { QuestionsAnswers.Add(new QuestionData()); SelectedPicture = new BitmapImage(); Pictures.Add(new BitmapImage()); QuestionText = ""; Alternative1Text = ""; Alternative2Text = ""; Alternative3Text = ""; Alt1Correct = false; Alt2Correct = false; Alt3Correct = false; } else { SelectedPicture = Pictures[SelectedQuestion - 1]; QuestionText = QuestionsAnswers[SelectedQuestion - 1].Question; Alternative1Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeOne; Alternative2Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeTwo; Alternative3Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeThree; var CA = QuestionsAnswers[SelectedQuestion - 1].Answer; if (CA == Alternative1Text) { Alt1Correct = true; Alt2Correct = false; Alt3Correct = false; } else if (CA == Alternative2Text) { Alt2Correct = true; Alt1Correct = false; Alt3Correct = false; } else if (CA == Alternative3Text) { Alt3Correct = true; Alt1Correct = false; Alt2Correct = false; } else { Alt1Correct = false; Alt2Correct = false; Alt3Correct = false; } } DeleteQuestionCommand.RaiseCanExecuteChanged(); }