/// <summary> /// Start button click handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WorkOnIt_Click(object sender, RoutedEventArgs e) { // Define type of source: folder, file, text... //_executorParams.Source = (CommandSource)StringReplacerTabs.SelectedIndex; StringBuilder result = new StringBuilder(); if (AddOperationsComboBox.SelectedIndex != -1) { Thread newWindowThread = new Thread(new ThreadStart(ShowProgressBar)); try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; // Create command execution class. CommandExecuter oper = new CommandExecuter(_executorParams, _commandParams); // Execute appropriate command. Number of selected command appropriate to its number in the Command collection. var cmd = _commands.GetCommand(AddOperationsComboBox.SelectedIndex); // Show progress bar in another thread. newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.IsBackground = true; newWindowThread.Start(); // Start operation in main thread. result = oper.ExecuteCommand(cmd); newWindowThread.Abort(); frmResults frm = new frmResults(result); frm.Show(); } catch (SimpleEditException ex) { newWindowThread.Abort(); System.Windows.MessageBox.Show(ex.Message); } catch (Exception) { newWindowThread.Abort(); System.Windows.MessageBox.Show((string)App.Current.FindResource("TextNotFoundError")); } Mouse.OverrideCursor = null; } else { System.Windows.MessageBox.Show((string)App.Current.FindResource("ErrorFillParameters")); } }
/// <summary> /// Start button click handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WorkOnIt_Click(object sender, RoutedEventArgs e) { // Define type of source: folder, file, text... //_executorParams.Source = (CommandSource)StringReplacerTabs.SelectedIndex; StringBuilder result = new StringBuilder(); if (AddOperationsComboBox.SelectedIndex != -1) { Thread newWindowThread = new Thread(new ThreadStart(ShowProgressBar)); try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; // Create command execution class. CommandExecuter oper = new CommandExecuter(_executorParams, _commandParams); // Execute appropriate command. Number of selected command appropriate to its number in the Command collection. var cmd = _commands.GetCommand(AddOperationsComboBox.SelectedIndex); // Show progress bar in another thread. newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.IsBackground = true; newWindowThread.Start(); // Start operation in main thread. result = oper.ExecuteCommand(cmd); newWindowThread.Abort(); frmResults frm = new frmResults(result); frm.Show(); } catch (SimpleEditException ex) { newWindowThread.Abort(); System.Windows.MessageBox.Show(ex.Message); } catch (Exception) { newWindowThread.Abort(); System.Windows.MessageBox.Show((string)App.Current.FindResource("TextNotFoundError")); } Mouse.OverrideCursor = null; } else System.Windows.MessageBox.Show((string)App.Current.FindResource("ErrorFillParameters")); }