public void ChooseNewQuestion() { IsLoading = true; int questionNumber = rnd.Next(0, QuestionList.Count); XamarinQuiz selectedItem = QuestionList[questionNumber]; Answer1Enabled = true; Answer2Enabled = true; Answer3Enabled = true; Answer4Enabled = true; Answer5Enabled = true; Answer6Enabled = true; Question = selectedItem.Question; Answer1 = selectedItem.Answer1; Answer2 = selectedItem.Answer2; Answer3 = selectedItem.Answer3; Answer4 = selectedItem.Answer4; Answer5 = selectedItem.Answer5; Answer6 = selectedItem.Answer6; CorrectAnswer = selectedItem.CorrectAnswer; IsLoading = false; }
public TwoQuiz(Game newGame) { InitializeComponent(); currentGame = newGame; XamarinQuiz item = new XamarinQuiz() { Question = "a man", Answer1 = "eine Frau", Answer2 = "ein Mann", Answer3 = "ein Auto", CorrectAnswer = 2 }; XamarinQuiz item2 = new XamarinQuiz() { Question = "a child", Answer1 = "ein Kind", Answer2 = "ein Haus", Answer3 = "ein Brotchen", CorrectAnswer = 1 }; XamarinQuiz item3 = new XamarinQuiz() { Question = "the hospital", Answer1 = "der Kranke", Answer2 = "das Ungesunde", Answer3 = "das Krankenhaus", CorrectAnswer = 3 }; XamarinQuiz item4 = new XamarinQuiz() { Question = "to read", Answer1 = "Fahren", Answer2 = "Rennen", Answer3 = "Lesen", CorrectAnswer = 3 }; XamarinQuiz item5 = new XamarinQuiz() { Question = "the teacher", Answer1 = "der Lehrer", Answer2 = "der Mann", Answer3 = "die Lehrerin", CorrectAnswer = 3 }; XamarinQuiz item6 = new XamarinQuiz() { Question = "snow", Answer1 = "Schnee", Answer2 = "Wind", Answer3 = "Regen", CorrectAnswer = 1 }; XamarinQuiz item7 = new XamarinQuiz() { Question = "the desk", Answer1 = "die Sessel", Answer2 = "der Tisch", Answer3 = "die Kopfhohrer", CorrectAnswer = 2 }; XamarinQuiz item8 = new XamarinQuiz() { Question = "a bird", Answer1 = "ein Hund", Answer2 = "eine Vogel", Answer3 = "ein Krokodil", CorrectAnswer = 2 }; IMobileServiceTable <XamarinQuiz> xamarinQuizTable = Settings1.MobileService.GetTable <XamarinQuiz>(); xamarinQuizTable.InsertAsync(item); xamarinQuizTable.InsertAsync(item2); xamarinQuizTable.InsertAsync(item3); xamarinQuizTable.InsertAsync(item4); xamarinQuizTable.InsertAsync(item5); xamarinQuizTable.InsertAsync(item6); xamarinQuizTable.InsertAsync(item7); xamarinQuizTable.InsertAsync(item8); ((TwoQuestionViewModel)BindingContext).LoadQuestions(); btnAnswerOne.Clicked += (sender, ea) => { if (((TwoQuestionViewModel)BindingContext).CheckIfCorrect(1)) { DoAnswer(); } else { score = score / 2; } }; btnAnswerTwo.Clicked += (sender, ea) => { if (((TwoQuestionViewModel)BindingContext).CheckIfCorrect(2)) { DoAnswer(); } else { score = score / 2; } }; btnAnswerThree.Clicked += (sender, ea) => { if (((TwoQuestionViewModel)BindingContext).CheckIfCorrect(3)) { DoAnswer(); } else { score = score / 2; } }; btnAnswerFour.Clicked += (sender, ea) => { if (((TwoQuestionViewModel)BindingContext).CheckIfCorrect(4)) { DoAnswer(); } else { score = score / 2; } }; btnAnswerFive.Clicked += (sender, ea) => { if (((TwoQuestionViewModel)BindingContext).CheckIfCorrect(5)) { DoAnswer(); } else { score = score / 2; } }; btnAnswerSix.Clicked += (sender, ea) => { if (((TwoQuestionViewModel)BindingContext).CheckIfCorrect(6)) { DoAnswer(); } else { score = score / 2; } }; }