private void initNewWord() { string word = textboxWord.Text.Trim(); if (word == "") { MessageBox.Show("Слово не указано", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return; } string transcription = textboxTranscription.Text.Trim(); string partOfSpeach = textboxPartOfSpeach.Text.Trim(); int result = 0; if (!int.TryParse(textboxStatus.Text.Trim(), out result)) { result = 1; } string audio = textboxAudio.Text.Trim(); DateTime insert = MyWord.DataTimeInsert; DateTime lastCall = DateTime.Now; IEnumerable <string> translate = GetEnumerable(textboxTranslate.Text, splitTranslate); IEnumerable <string> example = GetEnumerable(textboxExample.Text, splitExample); if (audio == null) { MessageBoxResult messageBoxResult = MessageBox.Show(messageNotAudio, messageWarning, MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.No) { return; } } wordSample = new WordSample(word, partOfSpeach, transcription, audio, new ObservableCollection <string>(translate), new ObservableCollection <string>(example), insert, lastCall, result); }
private void wordListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBox lb = sender as ListBox; int ind = lb.SelectedIndex; WordSample wordSample = lb.Items[ind] as WordSample; inerGrid.DataContext = wordSample; _wordsSample = inerGrid.DataContext as WordSample; ChengeIconButtonSave(pathRedTick, ColorIconButtonsave.Red); }
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' }; }
private void ClickButtonSave(object sender, RoutedEventArgs e) { if (GreateNewWord()) { ChengeIconButtonSave(pathGreenTick, ColorIconButtonsave.Green); int ind = BdTools.AddNewWords(_wordsSample); _wordsSample = new WordSample(); inerGrid.DataContext = null; } //imageButtonSave.Source = BitmapFrame.Create(new Uri(@"Picture\\tick_green.png", UriKind.Relative)); }
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(); }
public static int AddNewWords(WordSample wordSample) { int index = AddNewWord(wordSample.Word, wordSample.DateTimeInsert, wordSample.DateTimeLastCall, wordSample.SoundName, wordSample.PartOfSpeach, wordSample.Transcription); if (index > 0) { foreach (string trans in wordSample.Translate) { AddNewTranslate(trans, index); } foreach (string item in wordSample.Example) { AddNewExamle(item, index); } } return(index); }