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);
        }
        /// <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 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 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;
            }
        }