// Shows the given input length, coloring each letter green (correct) or red (incorrect). private void SetAnalyzedNameTextBox(String input) { Animal currentAnimal = animalSpelling.GetCurrentAnimal(); analyzedNameTextBlock.Inlines.Clear(); if (currentAnimal == null) { return; } UpdatePrompt(); VerifiedLetterCollection collection = animalSpelling.VerifyInput(input, currentAnimal.getAnimalName()); foreach (VerifiedLetter letter in collection.letters) { Media.Color color; if (letter.isCorrect) { color = Colors.Green; } else { color = Colors.Red; } analyzedNameTextBlock.Inlines.Add(animalSpelling.CreateRun(letter.letter, color)); } }
// Displays the current animal, if there is no animal left // shows the results page private void DisplayCurrentAnimal() { Animal currentAnimal = animalSpelling.GetCurrentAnimal(); imageBox.Source = new BitmapImage(currentAnimal.getAnimalImage()); userInputTextBox.MaxLength = currentAnimal.getAnimalName().Length; userInputTextBox.Text = String.Empty; analyzedNameTextBlock.Text = String.Empty; SetAnalyzedNameTextBox(""); UpdatePrompt(); }
// Returns the animal name public String getName() { return(animal.getAnimalName()); }