public static async Task PDFExportIncomplete() { var tokenSource = new CancellationTokenSource(); var token = tokenSource.Token; EventHandler canceledHandler = delegate { tokenSource.Cancel(); }; string filepath = Dialogs.BrowseFileToSave(Dialogs.PDF_FILE_EXTENSION, Dialogs.PDF_FILE_FILTER); if (!string.IsNullOrEmpty(filepath)) { var tasks = mainVM.File.Tasks; var controller = await((MetroWindow)mainWin).ShowProgressAsync(Dialogs.PROGRESS_TITLE, EXPORT_MSG, true); controller.Canceled += canceledHandler; var result = await Task.Run(() => exportPdf(getIncompleteOnly(tasks), filepath, token)); await controller.CloseAsync(); if (controller.IsCanceled) { result = false; } controller.Canceled -= canceledHandler; handleSaveResult(result); } }
public static bool FileSaveAs() { string filepath = Dialogs.BrowseFileToSave(Dialogs.XML_FILE_EXTENSION, Dialogs.XML_FILE_FILTER); if (filepath != null) { bool succeed = mainVM.Save(filepath); handleSaveResult(succeed); return(succeed); } return(true); }