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 FileInfo CopyAudio() { string path = ReadPath(); FileInfo filcopy = null; if (path == null) { MessageBox.Show("не удалось прочитать путь к папке с внешними аудиофайлами"); return(null); } FileInfo fileInfo = SearchFile(_wordsSample.SoundName, path); if (fileInfo == null) { System.Media.SystemSounds.Beep.Play(); MessageBox.Show("Аудиофайл не найден.\nУкажите файл в ручную."); return(null); } else { //filcopy = FIleTools.CopyTo(fileInfo, FIleTools.NameDirectoryAudio); filcopy = FIleTools.CopyTo(fileInfo, true); filcopy.IsReadOnly = false; _wordsSample.SoundName = filcopy.Name; } return(filcopy); }
private void InitElements() { textblockword.Text = currentMyWord.Word; MyWord[] arrMw = new MyWord[] { currentMyWord, GetRandoMyWord() }; List <int> random = MyTools.GetRandomInt(new List <int>() { 0, 1 }, 2); for (int i = 0; i < 2; i++) { MyWord mw = arrMw[random[i]]; arrButtons[i].DataContext = mw; TextBlock textblock = (TextBlock)arrButtons[i].Content; textblock.Text = MyTools.GetTranslate(mw); } textblocktop.Text = (myWords.Count - currentIndex).ToString(); if (isPlay) { FileInfo fi = FIleTools.SearchFile(currentMyWord.SoundName, FIleTools.NameDirectoryAudio); PlaySound(fi); } }
private void LitterTrue(Button buttontarget, Button buttonSender) { PaintGreen(buttontarget); buttonSender.Visibility = Visibility.Hidden; countAnswerTrue++; if (currentLitter < wordTrue.Length - 1) { currentLitter++; ColorBorderBrush(); } else { //успешное завершние слова if (myWords[currentWord].MyExamples.Count > 0) { textblockexample.Text = MyTools.ExampleSpace(myWords[currentWord].MyExamples.First().Example); } FileInfo fi = FIleTools.SearchFile(myWords[currentWord].SoundName, FIleTools.NameDirectoryAudio); if (fi != null) { PlaySound(fi); } buttonNext.Content = strFront; buttonNext.Background = backgroundButtonNextColor; imageWord.Visibility = Visibility.Visible; } }
private void buttonSound_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; string str = button.DataContext as string; if (str != null) { FileInfo sound; try { sound = FIleTools.SearchFile(str, FIleTools.NameDirectoryAudio); } catch (IOException ex) { MessageBox.Show(ex.Message); return; }; try { mediaPlayer = new MediaPlayer(); mediaPlayer.Open(new Uri(sound.FullName)); mediaPlayer.Play(); //mediaPlayer.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } } }
private void Play() { FileInfo fi = FIleTools.SearchFile(myWords[currentword].SoundName, FIleTools.NameDirectoryAudio); PlaySound(fi); textblockCountword.Text = (currentword + 1).ToString() + "/" + myWords.Count; }
private void SoundSearchAndPlay() { FileInfo fi = FIleTools.SearchFile(myWords[currentword].SoundName, FIleTools.NameDirectoryAudio); PlaySound(fi); textboxkword.Focus(); }
private void InitDbContext(MyWord w) { this.DataContext = w; FileInfo fi = FIleTools.SearchFile(w.SoundName, FIleTools.NameDirectoryAudio); textblockCountword.Text = (count + 1).ToString() + "/" + App.dataVariable.CountWordLearning; PlaySound(fi); }
private void buttonSound_Click(object sender, RoutedEventArgs e) { Button bt = sender as Button; string sound = bt.DataContext.ToString(); FileInfo fi = FIleTools.SearchFile(sound, FIleTools.NameDirectoryAudio); PlaySound(fi); }
/// <summary> /// обработчик вкладки меню "Открыть" /// открывает проводник и сохраняет в текстовый файл путь к внешней папке с аудиофайлами /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClickMenuItemOpen(object sender, RoutedEventArgs e) { DefaultDialogService dds = new DefaultDialogService(); dds.OpenFileDialog(); string pathDirectory = dds.GetDirectory(dds.FilePath); FIleTools.WritePath(FIleTools.NameFilePathes, pathDirectory, false); }
public ChoseWords() { InitializeComponent(); FIleTools.TotalCreateDirectory(); wordListView.ItemsSource = collection; _wordsSample = new WordSample(); InitMyXmlReader(); splitTranslate = new char[] { '\n', '.', ',', '!', ' ', ';', ':', '\r', '\t', '\v', '?', '/' }; splitExample = new char[] { '\n', '\r', '\t', '\v' }; }
/// <summary> /// обработчик вкладки меню "Копировать аудиофайл" /// открывает проводник и копирует файл /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClickMenuItemOpen(object sender, RoutedEventArgs e) { DefaultDialogService dds = new DefaultDialogService(); dds.OpenFileDialog(); string path = dds.FilePath; FileInfo fileInfo = new FileInfo(path); FIleTools.CopyTo(fileInfo, FIleTools.NameDirectoryAudio); textboxAudio.Text = fileInfo.Name.ToLower(); }
private void InitValue() { textblockWord.Text = trenings[count].Word; currentRandowValue = random.Next(countButton); arrButtons[currentRandowValue].DataContext = trenings[count]; arrButtons[currentRandowValue].Content = trenings[count].TranslateStr; buttonsix.Content = str; FileInfo fi = FIleTools.SearchFile(trenings[count].SoundName, FIleTools.NameDirectoryAudio); PlaySound(fi); textblockCountword.Text = (count + 1).ToString() + "/" + trenings.Count().ToString(); }
private void buttonSave_Click(object sender, RoutedEventArgs e) { string translate = textboxTranslation.Text; IEnumerable <string> translates = translate.Split(new char[] { ',', '.', '\n', '\r', ';' }).Select(n => n.Trim()).Where(n => Regex.IsMatch(n, "\\S")); string example = textboxExample.Text; IEnumerable <string> examples = example.Split(new char[] { ';' }).Select(n => n.Trim()); string word = textboxWord.Text.ToLower().Trim(); string audio = textboxAudio.Text.ToLower().Trim(); string transcription = textboxTranscrition.Text.ToLower().Trim(); if (word == "" || audio == "" || translate == "" || audioFile == null) { MessageBox.Show("Заполните все поля!"); return; } if (!File.Exists(FIleTools.NameDirectoryAudio + "/" + audioFile.Name)) { FileInfo copy = FIleTools.CopyTo(audioFile, true); copy.IsReadOnly = false; } WordSample _wordsSample = new WordSample(); _wordsSample.Word = word; _wordsSample.Translate = new ObservableCollection <string>(translates); _wordsSample.DateTimeInsert = DateTime.Now; _wordsSample.DateTimeLastCall = DateTime.Now; _wordsSample.State = (int)State.New; _wordsSample.SoundName = audioFile.Name; _wordsSample.Transcription = transcription; _wordsSample.Example = new ObservableCollection <string>(examples); _wordsSample.PartOfSpeach = ""; int st = 0; try { st = BdTools.AddNewWords(_wordsSample); } catch (Exception ex) { MessageBox.Show(ex.Message, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } Clear(); }
private FileInfo SearchFile(string name, string nameDirectory) { FileInfo file = null; try { file = FIleTools.SearchFile(name, nameDirectory); } catch (IOException ex) { MessageBox.Show(ex.Message); return(null); } return(file); }
private FileInfo SearchFile(string name, string nameDirectory) { FileInfo file = null; try { file = FIleTools.SearchFile(name, nameDirectory); } catch (IOException ex) { MessageBox.Show(ex.Message, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } return(file); }
private string ReadPath() { string path; try { path = FIleTools.ReadPath(FIleTools.NameFilePathes); } catch (IOException ex) { MessageBox.Show(ex.Message); return(null); } return(path); }
/// <summary> /// Заполняем _wordsSample новыми значениями /// </summary> private bool GreateNewWord() { string word = textBoxWord.Text; if (word == "") { MessageBox.Show("Слово не указано."); return(false); } if (listBoxETranslate.Items.Count < 1) { MessageBox.Show("Перевод не указан."); return(false); } if (_wordsSample.SoundName == null) { MessageBoxResult messageBoxResult = MessageBox.Show(messageNotAudio, messageWarning, MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.No) { return(false); } _wordsSample.Word = word.Trim(); _wordsSample.PartOfSpeach = textBoxPartOfSpeach.Text.Trim(); _wordsSample.Transcription = textBoxTranscription.Text.Trim(new char[] { ' ', '[', ']' }); return(true); } FileInfo file = FIleTools.SearchFile(_wordsSample.SoundName, FIleTools.NameDirectoryAudio); if (file == null) { FileInfo cory = CopyAudio(); if (cory == null) { MessageBoxResult messageBoxResult = MessageBox.Show(messageOfAudio, messageWarning, MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.No) { return(false); } } } _wordsSample.Word = word.Trim(); _wordsSample.PartOfSpeach = textBoxPartOfSpeach.Text.Trim(); _wordsSample.Transcription = textBoxTranscription.Text.Trim(new char[] { ' ', '[', ']' }); _wordsSample.DateTimeInsert = DateTime.Now; _wordsSample.DateTimeLastCall = DateTime.Now; _wordsSample.State = newState; return(true); }
private void buttonDelete_Click(object sender, RoutedEventArgs e) { Button but = sender as Button; int index = (int)but.DataContext; MyWord wordDel = BdTools.DeleteWord(index); FileInfo fileInfo = FIleTools.SearchFile(wordDel.SoundName, FIleTools.NameDirectoryAudio); collection.Remove(wordDel); try { File.Delete(fileInfo.FullName); } catch (Exception ex) { MessageBox.Show(ex.Message + MethodBase.GetCurrentMethod().DeclaringType.FullName); return; } }
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 MenuItemтDeletAudio_Click(object sender, RoutedEventArgs e) { IEnumerable <string> soundFilesDirect = FTPSinchronisation.GetListDirectoryLocal(false); IEnumerable <string> soundFilesDB = BdTools.GetAudio(); IEnumerable <string> except = soundFilesDirect.Except(soundFilesDB); if (except.Count() > 0) { string message = ""; foreach (string item in except) { FileInfo info = FIleTools.DeletFile(FIleTools.NameDirectoryAudio, item); message += info.Name + "\n"; } MessageBox.Show("Удалены лишнии файлы из папки:'SoundFiles':\n" + message, "Информация", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("В приложении нет аудиофайлов для удаления", "Информация", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void DeleteWord(int wordId) { BdTools.DeleteWord(wordId); //MyWord myWord = collection.Where(n => n.WordId == wordId).Single(); MyWord myWord = null; foreach (MyWord item in collection) { if (item.WordId == wordId) { myWord = item; } } if (myWord == null) { MessageBox.Show("Слово не найдено!", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } collection.Remove(myWord); FileInfo fileInfo = FIleTools.SearchFile(myWord.SoundName, FIleTools.NameDirectoryAudio); if (fileInfo != null) { fileInfo.IsReadOnly = false; try { File.Delete(fileInfo.FullName); } catch (Exception ex) { MessageBox.Show(ex.Message + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } } else { MessageBox.Show("Файл отсутствует в папке SoundFiles", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); } }
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; } }
public MainWindow() { InitializeComponent(); backgroundWorker = ((BackgroundWorker)this.FindResource("backgroundWorker")); backgroundWorkerLoadAudio = ((BackgroundWorker)this.FindResource("backgroundWorkerLoadAudio")); backgroundWorkerWriteDB = ((BackgroundWorker)this.FindResource("backgroundWorkerWriteDB")); backgroundWorkerWriteSeverAudio = ((BackgroundWorker)this.FindResource("backgroundWorkerWriteSeverAudio")); FIleTools.CreateDirectory(FIleTools.NameDirectoryAudio); FIleTools.CreateDirectory(FIleTools.NameDirectoryStorage); //StartNewThread(); textboxCountWord.Text = App.dataVariable.CountWordLearning.ToString(); textboxCounSelekt.Text = App.dataVariable.CountSelectWord.ToString(); textboxCountRepetition.Text = App.dataVariable.CountWordRepetition.ToString(); textboxCountMlSekRepetition.Text = App.dataVariable.CountMilisek.ToString(); textboxCountMlSekDelayRepetition.Text = App.dataVariable.CountMilisekDelay.ToString(); textboxCountTimeWork.Text = App.dataVariable.CountTimeWork.ToString(); textboxCountWordTrenings.Text = App.dataVariable.CountWordTrenings.ToString(); textboxCountWordSprint.Text = App.dataVariable.CountWordSprint.ToString(); gbrash = (SolidColorBrush)textblockMessage.Foreground; if (App.dataVariable.IsUpdateState == 1) { checkboxStatus.IsChecked = true; } }
private void buttonSound_Click(object sender, RoutedEventArgs e) { FileInfo fi = FIleTools.SearchFile(trenings[count].SoundName, FIleTools.NameDirectoryAudio); PlaySound(fi); }
private FileInfo IsExist(FileInfo file) { string nameFile = textBoxWord.Text.Trim().ToLower() + file.Extension; return(FIleTools.SearchFile(nameFile, FIleTools.NameDirectoryAudio)); }