Beispiel #1
0
        public async Task <BitmapSource> CreateDiagramImageAsync(double dpi, double margin,
                                                                 CancellationToken cancellationToken = default(CancellationToken),
                                                                 IIncrementalProgress progress       = null, IProgress <int> maxProgress = null)
        {
            try
            {
                // The image creator must be created on the UI thread so it can read the necessary view and view model data.
                var diagramImageCreator = new DataCloningDiagramImageCreator(DiagramViewModel, _diagramStyleProvider, _resourceDictionary);

                return(await Task.Factory.StartSTA(() =>
                                                   diagramImageCreator.CreateImage(dpi, margin, cancellationToken, progress, maxProgress), cancellationToken));
            }
            catch (OperationCanceledException)
            {
                return(null);
            }
        }
        private async Task <BitmapSource> CreateDiagramImageAsync(ProgressDialog progressDialog)
        {
            try
            {
                var diagramImageCreator = new DataCloningDiagramImageCreator(DiagramViewModel, DiagramStlyeProvider);
                var cancellationToken   = progressDialog.CancellationToken;

                return(await Task.Factory.StartSTA(() =>
                                                   diagramImageCreator.CreateImage(SelectedDpi, 10, cancellationToken, progressDialog.Progress), cancellationToken));
            }
            catch (OperationCanceledException)
            {
                return(null);
            }
            catch (OutOfMemoryException)
            {
                HandleOutOfMemory();
                return(null);
            }
        }
Beispiel #3
0
        public async Task <BitmapSource> CreateDiagramImageAsync(CancellationToken cancellationToken = default(CancellationToken),
                                                                 IIncrementalProgress progress       = null, IProgress <int> maxProgress = null)
        {
            try
            {
                // The image creator must be created on the UI thread so it can read the necessary view and view model data.
                var diagramImageCreator = new DataCloningDiagramImageCreator(_diagramViewModel, _diagramControl, _resourceDictionary);

                return(await Task.Factory.StartSTA(() =>
                                                   diagramImageCreator.CreateImage(ImageExportDpi.Value, ExportedImageMargin, cancellationToken, progress, maxProgress), cancellationToken));
            }
            catch (OperationCanceledException)
            {
                return(null);
            }
            catch (OutOfMemoryException)
            {
                HandleOutOfMemory();
                return(null);
            }
        }