private void ForwardClick(object sender, RoutedEventArgs e) { if (fileStatusLines.Count <= 0) { MessageBox.Show("You should choose scans", "No images were chosen", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(ExcelFilePath)) { MessageBox.Show("You should choose excel file", "No excel file was chosen", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { // Using background worker to asynchronously run work method. using (var worker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }) { pbw = new ProgressBarWindow(worker); worker.DoWork += OcrProcess; worker.ProgressChanged += Worker_ProgressChanged; worker.RunWorkerAsync(); pbw.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR"); } }
public void DoWorkWithProgress(string message, Func <Task> work) { var progress = new ProgressBarWindow(message); progress.Owner = Application.Current.MainWindow; progress.Loaded += async(s, e) => { try { await work(); } catch (Exception ex) { LogManager.GetLogger("ProgressWork").Error(ex); this.ShowMessage(new MessageViewModel() { Buttons = MessageBoxButton.OK, Title = "Error", Message = "An unexpected error occured." }); } finally { (s as Window).Close(); } }; progress.ShowDialog(); }
public void Open_Executed(object sender, ExecutedRoutedEventArgs e) { if (TreeFlow.Items.Count > 0) { if (MessageBox.Show("Zaten Mevcut Bir Proje Var.Bu Kurulumda Sadece bir Proje ile çalışabilirsiniz.!. Devam etmek istediğinize emin misiniz?", "Yeni Proje", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GetProjectList(); })); pbw = new ProgressBarWindow(); pbw.Owner = this; pbw.ShowDialog(); } else { return; } } else { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GetProjectList(); })); pbw = new ProgressBarWindow(); pbw.Owner = this; pbw.ShowDialog(); } }
public virtual void Execute(object parameter) { if (_canExecuteMethod != null && !_canExecuteMethod((T)parameter)) { return; } ProgressBarWindow progressDialog = new ProgressBarWindow(); Task task = new Task(() => { try { //Set synchronization context to capture the exceptions thrown from async void event handlers. SynchronizationContext.SetSynchronizationContext(new AsyncSynchronizationContext()); _executeMethod((T)parameter); } catch (Exception exception) { if (_errorHandler != null) { _errorHandler(exception); } } finally { CloseDialog(progressDialog); } }); task.Start(); progressDialog.ShowDialog(); }
private void OnSimulateStart(object sender, RoutedEventArgs e) { SimulateStart(this, e); if (dllmodel.SimuMode == SimulateDllModel.SIMUMODE_CHART) { pbwin = new ProgressBarWindow("当前进度", "正在选定时间范围内运行,请稍后。。。"); pbwin.WindowStartupLocation = WindowStartupLocation.CenterScreen; pbwin.ShowDialog(); } }
public Window() { InitializeComponent(); ProgressBarWindow progress = new ProgressBarWindow(); progress.ShowDialog(); StartPage startPage = StartPage.StartInstance; StartFrame.Navigate(startPage); }
private void Save_Click(object sender, RoutedEventArgs e) { if (fileStatusLines.Count <= 0) { MessageBox.Show("You should choose scans before saving", "No file was chosen", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(ExcelFilePath)) { MessageBox.Show("You should choose excel file before saving", "No excel file was chosen", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(savingFolderRun.Text)) { MessageBox.Show("You should specify saving folder", "Saving directory isn't specified", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { List <FileStatusLine> linesCopy = new List <FileStatusLine>(fileStatusLines);; var arguments = new object[9]; arguments[0] = linesCopy; arguments[1] = savingFolderRun.Text; arguments[2] = isResizeNeededCheckBx.IsChecked.Value; arguments[3] = isCompressNeededCheckBx.IsChecked.Value; arguments[4] = targetFormat.SelectedItem.ToString(); arguments[5] = Int32.Parse(resizeTxtBx.Text); arguments[6] = Int32.Parse(qualityTxtBx.Text); arguments[7] = googleSheetData; arguments[8] = ExcelFilePath; // Using background worker to asynchronously run work method. using (var worker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }) { pbw = new ProgressBarWindow(worker); worker.DoWork += SaveImagesAndExcelProcess; worker.ProgressChanged += Worker_ProgressChanged; worker.RunWorkerAsync(arguments); pbw.ShowDialog(); } ResetWindowState(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }