Beispiel #1
0
        private async Task <IReadOnlyList <IDiagramNode> > ShowProgressAndAddItemsAsync(IReadOnlyList <IModelEntity> modelEntities)
        {
            IReadOnlyList <IDiagramNode> diagramNodes = null;

            using (var progressDialog = UiServices.CreateProgressDialog("Adding model items:", modelEntities.Count))
            {
                progressDialog.ShowWithDelayAsync();

                try
                {
                    diagramNodes = await ShowEntitiesAsync(modelEntities, progressDialog.CancellationToken, progressDialog.Progress);
                }
                catch (OperationCanceledException)
                {
                }
            }

            return(diagramNodes);
        }
Beispiel #2
0
        private async Task ShowProgressAndUpdateModelAsync()
        {
            using (var progressDialog = UiServices.CreateProgressDialog("Updating model entities:"))
            {
                progressDialog.ShowWithDelayAsync();

                try
                {
                    await UpdateModelAsync(progressDialog.CancellationToken, progressDialog.Progress);

                    progressDialog.Reset("Updating diagram nodes:", DiagramServices.Nodes.Count);

                    await UpdateDiagramAsync(progressDialog.CancellationToken, progressDialog.Progress);
                }
                catch (OperationCanceledException)
                {
                }
            }
        }
Beispiel #3
0
        private async Task <IReadOnlyList <IDiagramNode> > ExtendModelAndDiagramAsync(IRoslynBasedModelEntity modelEntity)
        {
            IReadOnlyList <IDiagramNode> diagramNodes = null;

            using (var progressDialog = UiServices.CreateProgressDialog("Extending model with entities:"))
            {
                progressDialog.ShowWithDelayAsync();

                try
                {
                    await ExtendModelWithRelatedEntitiesAsync(modelEntity, progressDialog.CancellationToken, progressDialog.Progress);

                    progressDialog.Reset("Adding diagram nodes:");

                    diagramNodes = await ExtendDiagramAsync(modelEntity, progressDialog.CancellationToken, progressDialog.Progress);
                }
                catch (OperationCanceledException)
                {
                }
            }

            return(diagramNodes);
        }
Beispiel #4
0
        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 = UiServices.CreateProgressDialog("Generating image..", int.MaxValue))
            {
                progressDialog.ShowProgressNumber = false;
                progressDialog.ShowWithDelayAsync();

                try
                {
                    var bitmapSource = await UiServices.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)
                {
                }
            }
        }