public MainWindow() { InitializeComponent(); Loaded += async(sender, e) => { ProgressDialogController progressDialog = await ShowProgressDialog("Loading...", "Loading tasks...").ConfigureAwait(false); await Config.LoadConfig(); Dispatcher.Invoke(() => ProgramTitle.Content = Config.WindowTitle ?? "..."); Dispatcher.Invoke(() => { if (!Config.EnablePunishmentTasks) { PunishmentTasksGrid.IsEnabled = false; PunishmentTasksGrid.Visibility = Visibility.Collapsed; } }); progressDialog.SetProgress(0.8); await Task.Delay(100).ConfigureAwait(false); progressDialog.SetMessage("Loading Task Buttons..."); Dispatcher.Invoke(InitTaskButtons); await Task.Delay(130).ConfigureAwait(false); Dispatcher.Invoke(() => RemainingTasksLabel.Content = $"{GetAvailableTasksCount()}/{GetTotalTasksCount()}"); progressDialog.SetProgress(1); await progressDialog.CloseAsync().ConfigureAwait(false); }; }
// upload private async void BtUploadArchive_OnClick(object sender, RoutedEventArgs e) { if (!await ModPlusAPI.Web.Connection.HasAllConnectionAsync(1)) { await this.ShowMessageAsync(ModPlusAPI.Language.GetItem(LangItem, "msg23"), string.Empty); return; } if (File.Exists(_currentFileToUpload)) { ProgressDialogController controller = null; try { var settings = new MetroDialogSettings { AnimateShow = true, AnimateHide = true, DialogTitleFontSize = 20 }; controller = await this.ShowProgressAsync(ModPlusAPI.Language.GetItem(LangItem, "msg24"), string.Empty, false, settings); controller.Minimum = 0; controller.Maximum = 2; using (var client = ModPlusAPI.Web.ApiClient.CreateClient()) { controller.SetMessage(ModPlusAPI.Language.GetItem(LangItem, "msg25")); controller.SetProgress(1); await client.UploadUserFile(new[] { "DwgForBaseFromUsers" }, _currentFileToUpload, false, true); controller.SetMessage(ModPlusAPI.Language.GetItem(LangItem, "msg26")); controller.SetProgress(2); var emailSettings = await client.GetEmailSettings(); await SendEmailNotification(emailSettings); } await controller.CloseAsync(); await this.ShowMessageAsync( string.Empty, ModPlusAPI.Language.GetItem(LangItem, "msg27") + ": " + _currentFileToUpload + " " + ModPlusAPI.Language.GetItem(LangItem, "msg28") + Environment.NewLine + ModPlusAPI.Language.GetItem(LangItem, "msg29")); } catch (Exception exception) { if (controller != null) { await controller.CloseAsync(); } ExceptionBox.Show(exception); } } else { MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg22")); } }
protected override async void ReadLASFileAction() { ProgressDialogController progressDialogController = await _dialogCoordinator.ShowProgressAsync(this, "Please wait...", "Finding headings..."); progressDialogController.Maximum = 100; await Task.Run(() => { List <StageModel> stageModels = new List <StageModel>(); int numberOfRows = Sections[SelectedDataSectionIndex].Content.Count(); progressDialogController.SetMessage("Beginning to read data..."); progressDialogController.SetProgress(0); progressDialogController.Maximum = numberOfRows; for (int currentRow = 0; currentRow < numberOfRows; currentRow++) { string[] splitLine = Sections[SelectedDataSectionIndex].Content[currentRow].SplitOnWhitespace(); bool shouldUse = true; if (LASFilterModels.Any()) { foreach (LASFilterModel lasFilterModel in LASFilterModels) { shouldUse = splitLine[lasFilterModel.HeadingIndex].Contains(lasFilterModel.FilterText); if (shouldUse == false) { break; } } } if (shouldUse) { double x = double.Parse(splitLine[SelectedXHeadingIndex]); double y = double.Parse(splitLine[SelectedYHeadingIndex]); double z = double.Parse(splitLine[SelectedZHeadingIndex]); stageModels.Add(new StageModel { StageNumber = int.Parse(splitLine[SelectedStageHeadingIndex]), Position = new Point3D(x, y, z) }); } progressDialogController.SetMessage($"Reading row {currentRow} of {numberOfRows}..."); progressDialogController.SetProgress(currentRow); } MessengerInstance.Send((stageModels, _wellID), MessageTokenStrings.AddStagesToManager); }); await progressDialogController.CloseAsync(); }
protected override async void ReadExcelFileAction() { ProgressDialogController progressDialogController = await _dialogCoordinator.ShowProgressAsync(this, "Please wait...", "Finding headings..."); progressDialogController.Maximum = 100; await Task.Run(() => { IEnumerable <ExcelRangeBase> dataColumn = _excelUsedRange.Single(cell => cell.Address == DataColumnHeading); IEnumerable <ExcelRangeBase> stageColumn = _excelUsedRange.Single(cell => cell.Address == StageColumnHeading); IEnumerable <ExcelRangeBase> timestampColumn = _excelUsedRange.Single(cell => cell.Address == TimestampColumnHeading); progressDialogController.SetMessage("Headings found..."); progressDialogController.SetProgress(100); List <DataValueModel> values = new List <DataValueModel>(); int numberOfRows = _excelWorksheet.Dimension.Rows; progressDialogController.SetMessage("Beginning to read Worksheet..."); progressDialogController.SetProgress(0); progressDialogController.Maximum = numberOfRows; for (int currentRow = dataColumn.First().Start.Row; currentRow < numberOfRows; currentRow++) { object dataCellValue = _excelWorksheet.Cells[currentRow, dataColumn.First().Start.Column].Value; object stageCellValue = _excelWorksheet.Cells[currentRow, stageColumn.First().Start.Column].Value; object timestampCellValue = _excelWorksheet.Cells[currentRow, timestampColumn.First().Start.Column].Value; if (dataCellValue.IsNumeric() && stageCellValue != null && timestampCellValue != null && FilterRow(currentRow)) { values.Add(new DataValueModel { Stage = int.Parse(Regex.Match(_excelWorksheet.Cells[currentRow, stageColumn.First().Start.Column].Value.ToString(), @"\d+", RegexOptions.RightToLeft).Value), Value = double.Parse(_excelWorksheet.Cells[currentRow, dataColumn.First().Start.Column].Value.ToString()), Timestamp = DateTime.Parse(_excelWorksheet.Cells[currentRow, timestampColumn.First().Start.Column].Value.ToString().Replace("\"", ""), CultureInfo.InvariantCulture) }); } progressDialogController.SetMessage($"Reading row {currentRow} of {numberOfRows}..."); progressDialogController.SetProgress(currentRow); } DataSetModel dataSetModel = new DataSetModel { DataName = DataName, DataUnitOfMeasurement = DataUnitOfMeasurement, Values = values }; MessengerInstance.Send((dataSetModel, _wellID), MessageTokenStrings.AddDataToManager); }); await progressDialogController.CloseAsync(); }
private async Task RunTradeScripts(ProgressDialogController progressDialog) { List <UserScript> scripts; using (var dbContext = _contextFactory.Get()) { scripts = dbContext.UserScripts.Where(x => x.Type == UserScriptType.TradeScript).ToList(); } for (int i = 0; i < scripts.Count; i++) { progressDialog.SetProgress((double)i / scripts.Count); progressDialog.SetMessage("Running script: " + scripts[i].Name); try { await ScriptRunner.RunTradeScript(scripts[i]).ConfigureAwait(false); } catch (Exception ex) { _logger.Error(ex, "User script {0} generated an exception: ", scripts[i].Name); await DialogService.ShowMessageAsync(this, "Error", $"User script {scripts[i].Name} generated an exception. See log for more details."); } } }
private async void GeneratorProgressUpdate(object sender, ProgressEventArgs e) { if (e.IsFinished) { DumpTimigs(generator.Timing); ErrorsCount = generator.ErrorsCount; generator.Dispose(); excelStream.Dispose(); templateStream.Dispose(); await controller.CloseAsync(); if (Completed != null) { Completed(this, EventArgs.Empty); } } else { if (controller.IsCanceled) { generator.CancellationRequested = true; } controller.SetProgress(e.Progress); controller.SetMessage(e.StepName); } }
/// <summary> /// Initializes the control with a <see cref="MainWindow"/>. Necessary, as the <see cref="Window.GetWindow"/> method is unable to find a window for flyout controls. /// </summary> /// <param name="mainWindow">The <see cref="MainWindow"/>.</param> public void InitWindow(MainWindow mainWindow) { this.window = mainWindow; flyout = window.OSFlyout; flyout.IsOpenChanged += OsFlyoutOnIsOpenChanged; downloader = new WebClient( ); downloader.DownloadProgressChanged += (Sender, Args) => controller.SetProgress(Args.BytesReceived);; downloader.DownloadFileCompleted += DownloaderOnDownloadFileCompleted; LanguageList.SelectionChanged += (Sender, Args) => { bool HasSelection = LanguageList.SelectedItems.Count > 0; DownloadSubsLanguagesButton.IsEnabled = HasSelection; }; window.SizeChanged += (Sender, Args) => { if (!Args.WidthChanged) { return; } this.Width = Args.NewSize.Width * 0.8; }; }
private async void ExportEventSummaryToCSV(int?count = null) { Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.Summary); var saveDialog = new SaveFileDialog(); saveDialog.AddExtension = true; saveDialog.FileName = "band_export.csv"; saveDialog.DefaultExt = ".csv"; var result = saveDialog.ShowDialog(); if (result == true) { _summaryExportProgressDialog = await((MetroWindow)(Window.GetWindow(this))).ShowProgressAsync("Exporting Data", "..."); _summaryExportProgressDialog.SetCancelable(true); // TODO: this needs to be implemented. No event? _summaryExportProgressDialog.SetProgress(0); var progressIndicator = new Progress <BandCloudExportProgress>(ReportSummaryExportProgress); await BandCloudManager.Instance.ExportEventsSummaryToCSV(count, ExportSettings, saveDialog.FileName, progressIndicator); _summaryExportProgressDialog.CloseAsync(); if (ExportSettings.OpenFileAfterExport) { Process.Start(saveDialog.FileName); } SaveExportSettings(); } }
private static Task DownloadFile(string uri, string filename, MetroWindow window, ProgressDialogController controller) { return(Task.Run(() => { WebClient client = new WebClient(); client.DownloadProgressChanged += async(sender, e) => { double bytesIn = double.Parse(e.BytesReceived.ToString()); double totalBytes = double.Parse(e.TotalBytesToReceive.ToString()); double percentage = bytesIn / totalBytes * 100; try { await window.Dispatcher.InvokeAsync(() => { controller.SetProgress(int.Parse(Math.Truncate(percentage).ToString())); }); } catch { } }; client.DownloadFileCompleted += async(sender, e) => { await controller.CloseAsync(); client.Dispose(); }; client.DownloadFileAsync(new Uri(uri), Environment.CurrentDirectory + filename); })); }
// RootView progress; public async void ProgressDialog(DockManager progress, string word) { //progress = new RootView(); controller = await progress.ShowProgressAsync("Please wait...", word); Task.Delay(500); // controller.SetCancelable(true); double i = 0.0; while (i < 6.0) { double val = (i / 100.0) * 20.0; controller.SetProgress(val); controller.SetMessage(word + " in progress: " + i + "..."); if (controller.IsCanceled) { break; //canceled progressdialog auto closes. } i += 1.0; Task.Delay(200); } controller.CloseAsync(); // return progress; }
public async void ResultBarProgress(ResultView res, ResultViewModel vm) { int totalcount = 0; if (vm.BarValue == "CI") { totalcount = vm.Studentci.Count(); } else if (vm.BarValue == "TeachStep2") { totalcount = vm.Studentstep2.Count(); } else if (vm.BarValue == "TeachStep1") { totalcount = vm.Studentstep1.Count(); } controller = await res.ShowProgressAsync("Please wait...", vm.NoConditionResult.Count + " counts"); while (!vm.Done) { if (totalcount != 0) { controller.SetProgress((vm.NoConditionResult.Count / totalcount) * 100.0); } controller.SetMessage("Computing Result in progress: " + vm.NoConditionResult.Count + " counts..."); await Task.Delay(200); } controller.CloseAsync(); vm.CanShow = true; }
private async Task RemoveFilterEntriesAsync(Regex regex, ProgressDialogController controller) { var removeMessage = "Removing entry..."; await Task.Run(() => { var toRemove = DisplayedSongs .Where(x => !regex.IsMatch(x.Name)) .ToList(); controller.Minimum = 0; controller.Maximum = toRemove.Count; for (int i = 0; i < toRemove.Count; i++) { var currentItemNumber = i + 1; Application.Current.Dispatcher.Invoke(() => { DisplayedSongs.Remove(toRemove[i]); }); controller.SetProgress(currentItemNumber); controller.SetMessage(String.Format("{0} ({1}/{2})", removeMessage, currentItemNumber, toRemove.Count)); } }); }
private async void ConnectionManager_PluginUploadStarted(object sender, EventArgs e) { ProgressDialogController progressDialog = null; EventHandler <PluginUploadProgressChangedEventArgs> handler = null; var alreadyFinished = false; handler = (s, args) => { progressDialog?.SetProgress(args.Progress); progressDialog?.SetMessage( $"{FormatBytesConverter.BytesToString(args.BytesSent)} {Application.Current.Resources["Of"]} {FormatBytesConverter.BytesToString(args.TotalBytes)}"); if (Math.Abs(args.Progress - 1) < .1) { ((MainViewModel)DataContext).ConnectionManager.PluginUploadProgressChanged -= handler; progressDialog?.CloseAsync(); alreadyFinished = true; } }; ((MainViewModel)DataContext).ConnectionManager.PluginUploadProgressChanged += handler; progressDialog = await this.ShowProgressAsync((string)Application.Current.Resources["UploadingPlugin"], ""); if (alreadyFinished) { await progressDialog.CloseAsync(); } }
async void FinishTheJob() { ReceiveDialog.SetProgress(1); await ReceiveDialog.CloseAsync(); t1.Abort(); }
private async Task RunOrderScripts(List <Order> orders, ProgressDialogController progressDialog) { List <UserScript> scripts; using (var dbContext = _contextFactory.Get()) { scripts = dbContext.UserScripts.Where(x => x.Type == UserScriptType.OrderScript).ToList(); } for (int i = 0; i < scripts.Count; i++) { progressDialog.SetProgress((double)i / scripts.Count); progressDialog.SetMessage("Running script: " + scripts[i].Name); try { await ScriptRunner.RunOrderScript(scripts[i], orders);//todo: this will run subsequent scripts with orders set to a trade... orders = orders.Where(y => y.Trade == null).ToList(); } catch (Exception ex) { _logger.Error(ex, "User script {0} generated an exception: ", scripts[i].Name); await DialogService.ShowMessageAsync(this, "Error", $"User script {scripts[i].Name} generated an exception. See log for more details."); } } }
/// <summary> /// Runs CanEnable asynchronously multiple times until successful, cancelled or max tries reached /// </summary> /// <param name="dialog"></param> /// <returns></returns> public Task <bool> CanEnableAsync(ProgressDialogController dialog) { return(Task.Run(() => { for (var tries = 1; tries <= 10; tries++) { // Dialog interaction if (dialog != null) { // Stop if cancelled by user if (dialog.IsCanceled) { dialog.SetIndeterminate(); return false; } // Updated progress to indicate how much tries are left dialog.SetProgress(0.1 * tries); } if (CanEnable()) { dialog?.SetIndeterminate(); return true; } Thread.Sleep(2000); } dialog?.SetIndeterminate(); return false; })); }
/// <summary> /// Stuff that needs to be done after loading data from a statement. /// </summary> private async Task PostStatementLoadProcedures(Dictionary <string, DataContainer> newData, ProgressDialogController progressDialog) { progressDialog.SetProgress(0); progressDialog.SetTitle("Importing data"); progressDialog.SetMessage("Importing data"); //backup db before import System.IO.File.Copy("qpas.db", "qpas-backup.db", true); //prevent gaps in data bool continueImport = await ImportDateCheck(newData, progressDialog); if (!continueImport) { return; } //Perform the data import try { foreach (var kvp in newData) { await DataImporter.Import(Data, kvp.Value, kvp.Key, _contextFactory, _tradesRepository); } } catch (Exception ex) { await progressDialog.CloseAsync(); await DialogService.ShowMessageAsync(this, "Data Import Error", ex.Message); _logger.Error(ex, "Data import exception"); return; } //Run scripts progressDialog.SetProgress(0); progressDialog.SetTitle("Running scripts"); await RunOrderScripts(Data.Orders.Where(y => y.Trade == null).OrderBy(y => y.TradeDate).ToList(), progressDialog); await RunTradeScripts(progressDialog); await progressDialog.CloseAsync(); await RefreshCurrentPage(); }
private void OpenWorker_DoWork(object sender, DoWorkEventArgs e) { // Force this thread to work in EN Culture Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en"); // Get all the MP4 files in the chosen directory string[] inputFiles; string[] inputFolder = Directory.GetFiles(_inputPath, "*.mp4"); if (Directory.Exists(_inputPath + @"\RO")) { string[] inputFolderRO = Directory.GetFiles(_inputPath + @"\RO", "*.mp4"); inputFiles = inputFolder.Concat(inputFolderRO).ToArray(); } else { Log.WriteVerboseLine("RO Directory does not exist."); inputFiles = inputFolder; } // Set the progress status _progressDlg.Maximum = inputFiles.Count(); double count = 0; // Clear existing list of clips _clips.Clear(); Application.Current.Dispatcher.BeginInvoke(new Action(() => _journeyList.Clear())); foreach (string file in inputFiles) { Log.WriteLine("Info", "Loading file " + file); FileInfo fileInfo = new FileInfo(file); NovatekFile _file = new NovatekFile(fileInfo.DirectoryName, fileInfo.Name); if (_file.MoovBox != 0) { Log.WriteVerboseLine("File is a valid MP4 video file."); _clips.Add(_file); } else { Log.WriteLine("ERROR", "File at " + file + " does not seem to be a valid video file. File will be ignored."); } _progressDlg.SetProgress(count++); } }
protected virtual async void LoadLASFileCallback(FlyoutMessageModel flyoutMessage) { ResetProperties(); ProgressDialogController progressDialogController = await _dialogCoordinator.ShowProgressAsync(this, "Please wait...", "Awaiting user to select file..."); progressDialogController.Maximum = 100; await Task.Run(() => { progressDialogController.SetProgress(33); progressDialogController.SetMessage("Opening file..."); progressDialogController.SetProgress(66); progressDialogController.SetMessage("Reading Sections..."); using (StreamReader reader = new StreamReader(flyoutMessage.FileName)) { string line = reader.ReadLine(); while (!reader.EndOfStream) { if (line != null && line.StartsWith("~")) { LASSectionModel newSection = new LASSectionModel { Name = line }; newSection.Content = new List <string>(); line = reader.ReadLine(); while (line != null && !line.StartsWith("~")) { newSection.Content.Add(line); line = reader.ReadLine(); } Sections.Add(newSection); } } } }); await progressDialogController.CloseAsync(); }
public static void UpdateProgress(this ProgressDialogController controller, ProgressIndicator indicator) { if (indicator != null) { controller.SetProgress(indicator.Progress); controller.SetMessage(indicator.Message); } }
public void ReportProgress(float progress) { if (_controller == null) { return; } _controller.SetMessage(GetProgressMessage(progress)); _controller.SetProgress(progress); }
private async void ReceiveFile(object sender, RoutedEventArgs e) { result = await this.ShowProgressAsync("Receiving file", "Please wait...", true); FileReceiver receive = new FileReceiver(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\", result); result.SetProgress(.7); result.Canceled += CancelDialog; }
private void DownloadProgressed(object sender, DownloadProgressChangedEventArgs e) { // Handles percentage and MB downloaded/left dwJavaInCourse.SetMessage( $"{e.ProgressPercentage}% {Program.Translations.GetLanguage("AmountCompleted")}, " + $"{Program.Translations.GetLanguage("AmountDownloaded")} {Math.Round(ByteSize.FromBytes(e.BytesReceived).MegaBytes),0} MB / " + $"{Math.Round(ByteSize.FromBytes(e.TotalBytesToReceive).MegaBytes),0} MB"); // Handles progress bar dwJavaInCourse.SetProgress(e.ProgressPercentage * 0.01d); }
/// <summary> /// Displays the progress of building the index to the gui /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChangedBuildingIndexProgress(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage == 100) { try { _controller.CloseAsync(); } catch (Exception) {} } _controller.SetProgress(e.ProgressPercentage / 100.0); _controller.SetMessage(e.ProgressPercentage + "% of the files already added!"); }
public PdfDocument CopyPages(PdfDocument from, PdfDocument to, ProgressDialogController ctrl, FileInfo _in, FileInfo _out) { for (int i = 0; i < from.PageCount; i++) { ctrl.SetTitle($"Adding pages to {_out.Name}"); ctrl.SetMessage($"{i+1}/{from.PageCount} pages from {_in.Name}"); to.AddPage(from.Pages[i]); var progress = (((((i + 1f) * 100f)) / ((from.PageCount) * (100f)))); ctrl.SetProgress(progress); } return(to); }
private static async Task CleanUpGameFiles(ProgressDialogController controller) { var count = 0; int gamesCount; var lockMe = new object(); var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; await Task.Run(() => { var games = DeckStatsList.Instance.DeckStats.Values.SelectMany(x => x.Games).Concat(DefaultDeckStats.Instance.DeckStats.SelectMany(x => x.Games)).ToList(); gamesCount = games.Count; Parallel.ForEach(games, options, (game, loopState) => { if (controller.IsCanceled) { loopState.Stop(); return; } if (game.OpponentCards.Any()) { return; } var oppCards = GetOpponentDeck(game); if (oppCards.Any()) { game.SetOpponentCards(oppCards); } game.DeleteGameFile(); lock (lockMe) { controller.SetProgress(1.0 * ++count / gamesCount); } }); }); DeckStatsList.Save(); DefaultDeckStats.Save(); if (!controller.IsCanceled) { try { Directory.Delete(GamesDir, true); } catch (Exception e) { Log.Error(e); } } }
private async System.Threading.Tasks.Task InstallJava() { // Spawn progress dialog when downloading Java dwJavaInCourse = await this.ShowProgressAsync(Program.Translations.GetLanguage("DownloadingJava") + "...", Program.Translations.GetLanguage("FetchingJava"), false, MetroDialogOptions); dwJavaInCourse.SetProgress(0.0); ProcessUITasks(); // Setting up event callbacks to change download percentage, amount downloaded and amount left using WebClient wc = new WebClient(); wc.DownloadProgressChanged += DownloadProgressed; wc.DownloadFileCompleted += DownloadCompleted; wc.DownloadFileAsync(new Uri(JavaLink), OutFile); }
private void BW_LoadEDFFileUpDateProgress(object sender, DoWorkEventArgs e) { long process_start = Process.GetCurrentProcess().PagedMemorySize64; long file_size = (long)(new FileInfo(e.Argument.ToString()).Length * 2.2); long current_progress = 0; while (!bw_progressbar.CancellationPending) { current_progress = Math.Max(current_progress, Process.GetCurrentProcess().PagedMemorySize64 - process_start); double progress = Math.Min(99, (current_progress * 100 / (double)file_size)); try { controller.SetProgress(progress); } catch { break; } } }
public async Task UpdateProgressAsync(string message, double progress) { if (message != null) { _progressController.SetMessage(message); } _progressController.SetProgress(progress); if (progress >= _progressController.Maximum) { await _progressController.CloseAsync(); _progressController = null; } }
public void SavePDFsOn(ObservableCollection <ImageFile> imgs, ProgressDialogController ctrl) { try { int c = 0; ctrl.SetTitle("Converting to PDF"); ctrl.SetMessage($"{c}/{imgs.Count} Wait a moment..."); var bitmapsource = new ObservableCollection <BitmapSource>(); var outPdf = new PdfDocument(); foreach (ImageFile item in imgs) { bitmapsource.Add(ConvertScannedImage(item)); } foreach (BitmapSource item in bitmapsource) { var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(item as BitmapFrame)); using (FileStream stream = new FileStream($@"{_containerNname}.png", FileMode.Create)) encoder.Save(stream); ConvertImageToPDF(); var inputPdf = PdfReader.Open($"{_containerNname}.pdf", PdfDocumentOpenMode.Import); outPdf = CopyPages(inputPdf, outPdf); if (File.Exists($"{_containerNname}.pdf")) { File.Delete($"{_containerNname}.pdf"); } if (File.Exists($"{_containerNname}.png")) { File.Delete($"{_containerNname}.png"); } c++; ctrl.SetMessage($"{c}/{imgs.Count} Wait a moment..."); ctrl.SetProgress(c / imgs.Count); } outPdf.Save($"{_containerNname}.pdf"); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }