public static void ShowAppropriateToast(HourViewModel currentHour, QuestionViewModel oldQuestionState, Question currentQuestionState) { if (oldQuestionState.State == currentQuestionState.State) { Debug.WriteLine(string.Format("No toast displayed because oldQuestionState.{0} == currentQuestionState.{1}", oldQuestionState.State, currentQuestionState.State)); return; // If the state didn't change, don't show a toast } if (currentQuestionState.State == QuestionState.Open) { Debug.WriteLine(string.Format("No toast displayed because currentQuestionState.{0} == QuestionState.Open", currentQuestionState.State)); return; // no need to show toast } string imageKey; string text; ToastNotification.TriviaIndication indication; if (currentQuestionState.State == QuestionState.Wrong) { if (oldQuestionState.IsBeingResearched == false) { Debug.WriteLine(string.Format("No toast displayed because oldQuestionState.IsBeingResearched({0}) == false", oldQuestionState.IsBeingResearched)); return; // Don't show any toast if a question's closed that you weren't working on } // Just closed, didn't get an answer text = string.Format("Question #{0} Now Closed.", currentQuestionState.Identifier.Number); indication = ToastNotification.TriviaIndication.IncorrectQuestion; imageKey = GetImageForQuestion(currentQuestionState.Identifier.Hour, currentQuestionState.Identifier.Number, ToastFactory.WrongImages); // If it's a high-pointer, let's show a special meme instead if (currentQuestionState.Points >= 80) { imageKey = GetImageForQuestion(currentQuestionState.Identifier.Hour, currentQuestionState.Identifier.Number, ToastFactory.HighPointWrongImages); } } else if (currentQuestionState.State == QuestionState.Correct) { // Always show toast for correct questions (maybe in the future we should have a threshold) text = string.Format("Got Correct Answer for #{0} - {1} points!", currentQuestionState.Identifier.Number, currentQuestionState.Points); indication = ToastNotification.TriviaIndication.CorrectQuestion; imageKey = GetImageForQuestion(currentQuestionState.Identifier.Hour, currentQuestionState.Identifier.Number, ToastFactory.CorrectImages); } else { throw new InvalidOperationException("Toast in wrong place unexpectedly"); } ImageSource image = (ImageSource)ToastFactory.mImagesDictionary[imageKey]; bool shouldShowStopResearching = oldQuestionState.IsBeingResearched; ToastNotification toast = new ToastNotification(image); toast.Indication = indication; toast.BodyText = text; toast.Show(); // Extra toasts for special situations? if (currentQuestionState.Identifier.Number == 9 && currentHour.OpenQuestions.Count == 0 && currentHour.Questions.All(q => q.State == QuestionState.Correct)) { ToastNotification allofthethings = new ToastNotification((ImageSource)ToastFactory.mImagesDictionary["allofthethings"], false); allofthethings.Indication = indication; allofthethings.BodyText = "Perfect Hour"; allofthethings.Show(); } // If it's a low pointer that we missed, add an extra toast meme (only show the people researching though to avoid spam) if (currentQuestionState.State == QuestionState.Wrong && currentQuestionState.Points < 20) // Less than 20 points we'll consider small { ToastNotification fuckitbillmurray = new ToastNotification((ImageSource)ToastFactory.mImagesDictionary["fuckitbillmurray"], false); fuckitbillmurray.Indication = indication; fuckitbillmurray.BodyText = "Small Question Missed"; fuckitbillmurray.Show(); } // Always last/leftmost if (shouldShowStopResearching) { ToastNotification stopResearchingToast = new ToastNotification((ImageSource)ToastFactory.mImagesDictionary["StopResearching"], false); stopResearchingToast.Indication = indication; stopResearchingToast.BodyText = "Stop Researching This Question"; stopResearchingToast.Show(); } }
public static void ShowToastForPartial(Answer partialAnswer) { string imageKey = GetImageForQuestion(partialAnswer.Hour, partialAnswer.Number, ToastFactory.PartialImages); ImageSource image = (ImageSource)ToastFactory.mImagesDictionary[imageKey]; ToastNotification toast = new ToastNotification(image); toast.Indication = ToastNotification.TriviaIndication.PartialAnswer; toast.BodyText = string.Format("Partial confirmed for #{0}:{1}{2}", partialAnswer.Number, Environment.NewLine, partialAnswer.Text); toast.Show(); }