Exemplo n.º 1
0
        private void SoundSearchAndPlay()
        {
            FileInfo fi = FIleTools.SearchFile(myWords[currentword].SoundName, FIleTools.NameDirectoryAudio);

            PlaySound(fi);
            textboxkword.Focus();
        }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
        private void Play()
        {
            FileInfo fi = FIleTools.SearchFile(myWords[currentword].SoundName, FIleTools.NameDirectoryAudio);

            PlaySound(fi);
            textblockCountword.Text = (currentword + 1).ToString() + "/" + myWords.Count;
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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 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;
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        /// <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);
        }
Exemplo n.º 13
0
        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;
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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;
            }
        }
Exemplo n.º 16
0
        private FileInfo IsExist(FileInfo file)
        {
            string nameFile = textBoxWord.Text.Trim().ToLower() + file.Extension;

            return(FIleTools.SearchFile(nameFile, FIleTools.NameDirectoryAudio));
        }
Exemplo n.º 17
0
        private void buttonSound_Click(object sender, RoutedEventArgs e)
        {
            FileInfo fi = FIleTools.SearchFile(trenings[count].SoundName, FIleTools.NameDirectoryAudio);

            PlaySound(fi);
        }