private void txtInput_PreviewKeyUp(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Z) { notPressedZ = true; DitSoundManager.stopPlaying(); } else if (e.Key == VirtualKey.X) { notPressedX = true; DahSoundManager.stopPlaying(); } else if (e.Key == VirtualKey.Right) { DahSoundManager.setSource(); } }
private void txtInput_PreviewKeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Left) { if (lblWordOnDeck.Text != "") { wordOnDeck.Clear(); inputDisplay.Clear(); inputConvert.Clear(); lblWordOnDeck.Text = ""; } else { string ToCut = outputDisplay.ToString(); if (ToCut.Length > 0) { outputDisplay.Clear(); int i = ToCut.LastIndexOf(" "); outputDisplay.Append(ToCut.Substring(0, i)); } //txtOutput.Text = outputDisplay.ToString(); txtOutputText.Text = outputDisplay.ToString(); } DahSoundManager.setSource(); DitSoundManager.setSource(); } else if (e.Key == VirtualKey.Right) { if (letterOnDeck == "") { if (wordOnDeck.ToString() != "") { outputDisplay.Append(" " + wordOnDeck.ToString()); //txtOutput.Text = outputDisplay.ToString(); txtOutputText.Text = outputDisplay.ToString(); lblWordOnDeck.Text = ""; wordOnDeck.Clear(); } } else { if (letterOnDeck != "#") { wordOnDeck.Append(letterOnDeck); } else { lblWordOnDeck.Text = wordOnDeck.ToString(); } } inputDisplay.Clear(); inputConvert.Clear(); letterOnDeck = ""; DahSoundManager.setSource(); DitSoundManager.setSource(); } else if (e.Key == VirtualKey.Z && notPressedZ) { if (inputDisplay.Length < maxLength) { inputDisplay.Append("."); inputConvert.Append("z"); enumOnDeck = Converter.morseStringToEnum(inputConvert.ToString()); letterOnDeck = Converter.EnumToString(enumOnDeck); lblWordOnDeck.Text = wordOnDeck.ToString() + letterOnDeck; notPressedZ = false; DahSoundManager.stopPlaying(); DitSoundManager.play550Hzshort(); } } else if (e.Key == VirtualKey.X && notPressedX) { if (inputDisplay.Length < maxLength) { inputDisplay.Append("-"); inputConvert.Append("x"); enumOnDeck = Converter.morseStringToEnum(inputConvert.ToString()); letterOnDeck = Converter.EnumToString(enumOnDeck); lblWordOnDeck.Text = wordOnDeck.ToString() + letterOnDeck; notPressedX = false; DitSoundManager.stopPlaying(); DahSoundManager.play545Hz(); } } else { DitSoundManager.stopPlaying(); DahSoundManager.stopPlaying(); } txtInput.Text = inputDisplay.ToString(); }