/** Purpose : Maintaing the homogenity of the text and toggling the activation of Go button * * Correct the text by eliminating all the invalid characters * Change the contents of the source with the next text * Update the contents of the Go buttton and enable or disable it */ private void LetterArraySource_TextChanged(object sender, TextChangedEventArgs e) { if (LetterArraySource.Text != "Type the sequence here") { string correctedText = ""; foreach (var letter in LetterArraySource.Text) { if (letter >= 'a' && letter <= 'z' || letter >= 'A' && letter <= 'Z') { correctedText += letter; } } LetterArraySource.Text = correctedText; LetterArraySource.Select(correctedText.Length, 0); if (correctedText.Length == 16) { Go.IsEnabled = true; Go.Content = "Go!"; } else { Go.IsEnabled = false; Go.Content = correctedText.Length; } } }
/** Purpose : Clears the contents of the Source textbox and clears its contents * * If the text is the default text then * Clear the text and set the font style to NORMAL */ private void LetterArraySource_GotFocus(object sender, RoutedEventArgs e) { if (LetterArraySource.Text == "Type the sequence here") { LetterArraySource.FontStyle = FontStyles.Normal; LetterArraySource.Clear(); } }
/** Purpose : Assigning new Data and starting the GoButton Animation * * We are now supposed to update the contents of the Buttons * By taking the data from the LetterArraySource * Reset the formatting specifications of the TextBox * Clear the contents of the word list in transaction lock mode * Start the animation of the button */ private void Go_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cellObject[i, j].UpdateData(LetterArraySource.Text[i * 4 + j]); } } LetterArraySource.Text = "Type the sequence here"; LetterArraySource.FontStyle = FontStyles.Italic; LetterArraySource.SelectAll(); WordList.IsEnabled = false; WordList.Items.Clear(); WordList.IsEnabled = true; Go.Content = 0; Go.IsEnabled = false; goAnimation.Start(); }