private void btnSearch_Click(object sender, RoutedEventArgs e) { frmChooseLangs lang = new frmChooseLangs(TranslationManage.languages); string langIDs = lang.LanguageIDs; if (string.IsNullOrEmpty(txtSearch.Text)) { MessageBox.Show("Please input strings what you need to search!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); txtSearch.Focus(); } else if (string.IsNullOrEmpty(langIDs)) { MessageBox.Show("Please select languages!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } else { bool? isFront = cbFront.IsChecked; bool? isLast = cbLast.IsChecked; string keyString = txtSearch.Text; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (o, ea) => { try { DataTable dt = transManage.FuzzyQuery(keyString, langIDs, isFront, isLast); Dispatcher.Invoke(new Action(() => dgFuzzyList.ItemsSource = dt.DefaultView)); SetStatusLabelValue(tsslblException, ""); } catch (Exception ex) { ea.Result = ex; } }; worker.RunWorkerCompleted += (o, ea) => { pBar.Visibility = Visibility.Hidden; if (ea.Result != null) { SetStatusLabelValue(tsslblException, "Warning : " + ea.Result); } }; SetStatusLabelValue(tsslblException, ""); pBar.Visibility = Visibility.Visible; worker.RunWorkerAsync(); } }
private void btnChooseLangs_Click(object sender, RoutedEventArgs e) { frmChooseLangs frmLangs = new frmChooseLangs(TranslationManage.languages); frmLangs.ShowDialog(); }