private void CombinePdfs(ProgressDialog dialog) { dialog.ReportProgress(100, "正在合并,请稍后", "合并中..."); var pdfs = Directory.GetFiles(PdfFolderTemp, "*.pdf"); Converter.Combine(pdfs, PdfFileName); Directory.Delete(PdfFolderTemp, true); }
private void OnBruteForce() { IsBruteForceAvailable = false; var progDlg = new Ookii.Dialogs.Wpf.ProgressDialog(); progDlg.WindowTitle = "Brute-forcing"; progDlg.Text = "This is going to take a while..."; progDlg.DoWork += DoBruteForceWork; progDlg.RunWorkerCompleted += OnBruteForceComplete; progDlg.ShowDialog(System.Windows.Application.Current.MainWindow); progDlg.ProgressBarStyle = Ookii.Dialogs.Wpf.ProgressBarStyle.ProgressBar; progDlg.ShowTimeRemaining = true; }
private async Task<string> DownloadWithProgress(Uri downloadUri, string packageId, string packageVersion) { string progressDialogText = Resources.Resources.Dialog_DownloadingPackage; if (!String.IsNullOrEmpty(packageId)) { progressDialogText = String.Format(CultureInfo.CurrentCulture, progressDialogText, packageId, packageVersion); } else { progressDialogText = String.Format(CultureInfo.CurrentCulture, progressDialogText, downloadUri, String.Empty); } _progressDialog = new ProgressDialog { Text = progressDialogText, WindowTitle = Resources.Resources.Dialog_Title, ShowTimeRemaining = true, CancellationText = "Canceling download..." }; _progressDialog.ShowDialog(MainWindow.Value); // polling for Cancel button being clicked var cts = new CancellationTokenSource(); var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) }; timer.Tick += (o, e) => { if (_progressDialog.CancellationPending) { timer.Stop(); cts.Cancel(); } }; timer.Start(); try { string tempFilePath = await DownloadData(downloadUri, OnReportProgress, cts.Token); return tempFilePath; } catch (OperationCanceledException) { return null; } catch (Exception exception) { OnError(exception); return null; } finally { timer.Stop(); // close progress dialog when done lock (_progressDialogLock) { _progressDialog.Close(); _progressDialog = null; } MainWindow.Value.Activate(); } }
public bool Run() { Directory.SetCurrentDirectory (m_main.CurrentPath); var items = m_main.CurrentDirectory.SelectedItems.Cast<EntryViewModel> (); if (string.IsNullOrEmpty (m_arc_name)) { m_arc_name = Path.GetFileName (m_main.CurrentPath); if (!items.Skip (1).Any()) // items.Count() == 1 { var item = items.First(); if (item.IsDirectory) m_arc_name = Path.GetFileNameWithoutExtension (item.Name); } } var dialog = new CreateArchiveDialog (m_arc_name); dialog.Owner = m_main; if (!dialog.ShowDialog().Value) { return false; } if (string.IsNullOrEmpty (dialog.ArchiveName.Text)) { m_main.SetStatusText ("Archive name is empty"); return false; } m_format = dialog.ArchiveFormat.SelectedItem as ArchiveFormat; if (null == m_format) { m_main.SetStatusText ("Format is not selected"); return false; } m_options = dialog.ArchiveOptions; if (m_format.IsHierarchic) m_file_list = BuildFileList (items, AddFilesRecursive); else m_file_list = BuildFileList (items, AddFilesFromDir); m_arc_name = Path.GetFullPath (dialog.ArchiveName.Text); m_progress_dialog = new ProgressDialog () { WindowTitle = guiStrings.TextTitle, Text = string.Format (guiStrings.MsgCreatingArchive, Path.GetFileName (m_arc_name)), Description = "", MinimizeBox = true, }; m_progress_dialog.DoWork += CreateWorker; m_progress_dialog.RunWorkerCompleted += OnCreateComplete; m_progress_dialog.ShowDialog (m_main); return true; }