private void buttonFindAudio_Click(object sender, RoutedEventArgs e) { try { string word = textboxWord.Text; if (word == "") { MessageBox.Show("Введите слово!"); return; } string path = FIleTools.ReadPath(FIleTools.NameFilePathes); word += ".wav"; audioFile = FIleTools.SearchFile(word, path); if (audioFile == null) { MessageBox.Show("Аудиофайл не найден!\nУкажите файл в ручную."); return; } else { textboxAudio.Text = audioFile.Name; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } }
private string ReadPath() { string path; try { path = FIleTools.ReadPath(FIleTools.NameFilePathes); } catch (IOException ex) { MessageBox.Show(ex.Message); return(null); } return(path); }
private void SaveResult() { if (File.Exists(pathFile)) { string str = FIleTools.ReadPath(pathFile); int result = 0; int.TryParse(str, out result); if (currentTotal > result) { result = currentTotal; FIleTools.WritePath(pathFile, result.ToString(), false); } textBlockTop.Text = "Лучший результат: " + result + " очков"; } else { FIleTools.WritePath(pathFile, currentTotal.ToString(), false); textBlockTop.Text = "Лучший результат: " + currentTotal + " очков"; } }
private void buttonSearchAudio_Click(object sender, RoutedEventArgs e) { try { string directAudio = FIleTools.ReadPath(FIleTools.NameFilePathes); if (directAudio == null) { MessageBox.Show("Не указан путь к папке с аудиофайлами!", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } string wordAudio = textBoxWord.Text; if (wordAudio == "" || wordAudio == null) { MessageBox.Show("Укажите слово!"); return; } wordAudio = wordAudio.ToLower() + ".wav"; FileInfo audio = FIleTools.SearchFile(wordAudio, directAudio); if (audio == null) { MessageBox.Show("Аудиофайл не найден!\nУкажите файл в ручную. "); return; } else { FileInfo filcopy = FIleTools.CopyTo(audio, true); filcopy.IsReadOnly = false; _wordsSample.SoundName = filcopy.Name; MessageBox.Show("Аудиофайл успешно скопирован!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } }