public MainWindow() { InitializeComponent(); // Initialize messageQueue and Assign it to Snack bar's MessageQueue var messageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(2)); Snackbar.MessageQueue = messageQueue; // Initialize CiphersComboBox CiphersComboBox.ItemsSource = CiphersList.Instance; CiphersComboBox.DisplayMemberPath = "DisplayName"; // Initialize NewCipherDialog NewCipherDialog.Context = this; // Disable Actions EnableActions(false); // Clear initial block from RichTextBoxes InputRichTextBox.Clear(); OutputRichTextBox.Clear(); // Check for updates CheckForUpdates(); }
private void InputRichTextBox_OnSelectionChanged(object sender, RoutedEventArgs e) { if (MirrorToggleButton.IsChecked == false) { return; } OutputRichTextBox.ClearFormatting(); if (InputRichTextBox.Selection.IsEmpty || OutputRichTextBox.IsEmpty() || _containKeys) { return; } var inputStartPointer = InputRichTextBox.GetStart(); var outputStartPointer = OutputRichTextBox.GetStart(); var selectionStartPointer = InputRichTextBox.Selection.Start; var selectedText = InputRichTextBox.Selection.Text; var precedingText = new TextRange(inputStartPointer, selectionStartPointer).Text; var encodedSelectedText = _selectedCipher.Encode(selectedText, CharsDelimiter, WordsDelimiter); var encodedPrecedingText = _selectedCipher.Encode(precedingText, CharsDelimiter, WordsDelimiter); var highlightStartPointer = outputStartPointer.GetPositionAtOffset(encodedPrecedingText.Length + 2); var highlightEndPointer = highlightStartPointer?.GetPositionAtOffset(encodedSelectedText.Length + 2); var highlightTextRange = new TextRange(highlightStartPointer, highlightEndPointer); var brush = _isLight ? Brushes.Yellow : Brushes.DarkMagenta; highlightTextRange.ApplyPropertyValue(TextElement.BackgroundProperty, brush); }
private void Encode() { var text = InputRichTextBox.GetText(); var encodedText = _selectedCipher.Encode(text, CharsDelimiter, WordsDelimiter); OutputRichTextBox.SetText(encodedText); }
public Form12_type_text() { InitializeComponent(); ChangeLanguage(); UserInput = new List <string>(); //the no. of input char, start from 0 CurrentChar = new List <int>(); //the prompt index, the no. of line rightInput = ""; currentPrompt = 0; //read the prompts(lines) into the prompts list Prompts = new List <string>(); WordComboBox_init("course\\text\\article"); var path = Properties.Settings.Default.type_article_path; TextReader reader = File.OpenText(path); MAX_PROMPTS = File.ReadLines(path).Count(); //initialize all our lists for (int i = 0; i < MAX_PROMPTS; i++) { Prompts.Add(reader.ReadLine().Trim()); UserInput.Add(""); CurrentChar.Add(0); } Prompts.Shuffle_List(); reader.Close(); Prompts.Add(""); UserInput.Add(""); CurrentChar.Add(0); tm.Start(); timer1.Start(); var promptText = Prompts[0]; TextBoxDisplay_Config(promptText); InputRichTextBox.Focus(); }
private void inputRichTextBox_TextChanged(object sender, EventArgs e) { var inputText = InputRichTextBox.Text; var wd = Prompts[currentPrompt]; //when we hit the end of a prompt, switch to the next prompt if (inputText.Length == wd.Length) { if (object.Equals(wd, inputText)) { _stats.Update(true); } else { _stats.Update(false); } } else { } if (InputRichTextBox.Text.Contains(Prompts[currentPrompt]) == false) { var idx = PromptRichTextBox.Text.IndexOf(wd, StringComparison.CurrentCulture); if (inputText.Length <= Prompts[currentPrompt].Length && inputText.Length > 0) { PromptRichTextBox.ColorChar(idx + inputText.Length - 1, wd.Length - inputText.Length + 1, Color.Gray); var in_ch = inputText[inputText.Length - 1]; var right_ch = Prompts[currentPrompt][inputText.Length - 1]; if (in_ch == right_ch) { PromptRichTextBox.ColorChar(idx + inputText.Length - 1, 1, Color.Gray); InputRichTextBox.ColorChar(inputText.Length - 1, 1, Color.Gray); "audio//sys//type.wav".PlayWave(Properties.Settings.Default.type_effect); } else { PromptRichTextBox.ColorChar(idx + inputText.Length - 1, 1, Color.Red); InputRichTextBox.ColorChar(inputText.Length - 1, 1, Color.Red); "audio//sys//error.wav".PlayWave(Properties.Settings.Default.type_effect); } } else if (inputText.Length > Prompts[currentPrompt].Length) { InputRichTextBox.ColorChar(inputText.Length - 1, 1, Color.Red); "audio//sys//error.wav".PlayWave(Properties.Settings.Default.type_effect); } else if (inputText.Length == 0) { PromptRichTextBox.ColorChar(idx, 1, Color.Gray); } } else { rightInput += inputText; CurrentChar[currentPrompt]++; if (currentPrompt < MAX_PROMPTS - 1) { ShowNextPrompt(); } else if (currentPrompt == MAX_PROMPTS - 1) { ShowFinalScreen(); } } }
private void InputClearButton_Click(object sender, RoutedEventArgs e) { InputRichTextBox.Clear(); }
private void InputPasteButton_Click(object sender, RoutedEventArgs e) { InputRichTextBox.AppendText(Clipboard.GetText()); }
private void InputCopyButton_Click(object sender, RoutedEventArgs e) { InputRichTextBox.CopyToClipboard(); }