private void btnParseDictionary_Click(object sender, RoutedEventArgs e) { string title = txtNewDictionaryName.Text; if (!File.Exists(txtSourceDictionaryPath.Text)) { MessageBox.Show(Resources["specifiedDictionaryPathIncorrect"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (string.IsNullOrWhiteSpace(title) || title.Length > 200) { MessageBox.Show(Resources["enterDictionaryTitle"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (cbDictionaryTermLanguage.SelectedItem == null || cbDictionaryDescriptionLanguage.SelectedItem == null) { MessageBox.Show(Resources["termsAndDefinitionsLanguagesRequired"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (txtDictionaryNote.Text.Length > 500) { MessageBox.Show(Resources["noteSizeLimited"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Information); return; } int termLanguageId = ((Language)cbDictionaryTermLanguage.SelectedItem).Id; int definitionLanguageId = ((Language)cbDictionaryDescriptionLanguage.SelectedItem).Id; ProgressWindow progressWindow = new ProgressWindow(new Dictionary(0, title, termLanguageId, definitionLanguageId, txtDictionaryNote.Text), txtSourceDictionaryPath.Text); progressWindow.ShowDialog(); if (progressWindow.FinishedSuccesfull) { MessageBox.Show(Resources["importFinished"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(Resources["cantImportDictionary"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnParseText_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtSourceText.Text)) { MessageBox.Show(Resources["sourceTextRequired"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (string.IsNullOrWhiteSpace(txtVocabularyTitle.Text) || txtVocabularyTitle.Text.Length > 200) { MessageBox.Show(Resources["enterVocabularyTitle"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Information); return; } if (cbBasicDictionary.SelectedItem == null) { MessageBox.Show(Resources["selectBasicDictionary"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Information); return; } if (txtVocabularyNote.Text.Length > 500) { MessageBox.Show(Resources["noteSizeLimited"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Information); return; } int baseDictionaryId = ((Dictionary)cbBasicDictionary.SelectedItem).Id; Vocabulary vocabulary = new Vocabulary(0, txtVocabularyTitle.Text, baseDictionaryId, txtVocabularyNote.Text); int vocabularyId = DB.Vocabulary.CreateVocabulary(vocabulary); if (vocabularyId != 0) { vocabulary = new Vocabulary(vocabularyId, txtVocabularyTitle.Text, baseDictionaryId, txtVocabularyNote.Text); ProgressWindow progressWindow = new ProgressWindow(txtSourceText.Text, vocabulary); progressWindow.ShowDialog(); UpdateVocabulariesList(); if (progressWindow.FinishedSuccesfull) MessageBox.Show(Resources["vocabularyCreated"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(Resources["cantCreateVocabulary"].ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Error); } }