private async Task ShowProgressAndUpdateModelAsync() { using (var progressDialog = UiService.CreateProgressDialog("Updating model nodes:")) { progressDialog.ShowWithDelayAsync(); try { await UpdateModelAsync(progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } }
private async Task <IReadOnlyList <IDiagramNode> > ShowProgressAndAddItemsAsync(IReadOnlyList <IRoslynModelNode> modelEntities) { IReadOnlyList <IDiagramNode> diagramNodes = null; using (var progressDialog = UiService.CreateProgressDialog("Adding model items:", modelEntities.Count)) { progressDialog.ShowWithDelayAsync(); try { diagramNodes = await ShowEntitiesAsync(modelEntities, progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } return(diagramNodes); }
private async Task <IReadOnlyList <IDiagramNode> > ExtendModelAndDiagramAsync(IRoslynModelNode modelNode) { IReadOnlyList <IDiagramNode> diagramNodes = null; using (var progressDialog = UiService.CreateProgressDialog("Extending model with entities:")) { progressDialog.ShowWithDelayAsync(); try { await ExtendModelWithRelatedEntitiesAsync(modelNode, progressDialog.CancellationToken, progressDialog.Progress); progressDialog.Reset("Adding diagram nodes:"); diagramNodes = await ExtendDiagramAsync(modelNode, progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } return(diagramNodes); }
protected async Task CreateAndProcessDiagramImageAsync(Action <BitmapSource> imageProcessingAction, string imageProcessingMessage) { // Using int.MaxValue for max progress because the real max value is not yet known. using (var progressDialog = UiService.CreateProgressDialog("Generating image..", int.MaxValue)) { progressDialog.ShowProgressNumber = false; progressDialog.ShowWithDelayAsync(); try { var bitmapSource = await UiService.CreateDiagramImageAsync(progressDialog.CancellationToken, progressDialog.Progress, progressDialog.MaxProgress); if (bitmapSource != null) { progressDialog.Reset(imageProcessingMessage, showProgressNumber: false); await Task.Factory.StartSTA(() => imageProcessingAction(bitmapSource), progressDialog.CancellationToken); } } catch (OperationCanceledException) { } } }