Exemplo n.º 1
0
        private void LoadVolume(IBackgroundTaskContext context)
        {
            try
            {
                ProgressTask mainTask = new ProgressTask();
                mainTask.AddSubTask("BUILD", 90);
                mainTask.AddSubTask("LAYOUT", 10);

                context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, string.Format(SR.MessageInitializingMpr, mainTask.Progress)));

                BackgroundTaskParams @params = (BackgroundTaskParams)context.UserState;
                Volume volume = Volume.Create(@params.Frames,
                                              delegate(int i, int count)
                {
                    if (context.CancelRequested)
                    {
                        throw new BackgroundTaskCancelledException();
                    }
                    if (i == 0)
                    {
                        mainTask["BUILD"].AddSubTask("", count);
                    }
                    mainTask["BUILD"][""].Increment();
                    string message = string.Format(SR.MessageBuildingMprVolumeProgress, mainTask.Progress, i + 1, count, mainTask["BUILD"].Progress);
                    context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, message));
                });

                mainTask["BUILD"].MarkComplete();
                context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, string.Format(SR.MessagePerformingMprWorkspaceLayout, mainTask.Progress)));

                //call layout here b/c it could take a while
                @params.SynchronizationContext.Send(delegate
                {
                    _viewer = new MprViewerComponent(volume);
                    _viewer.Layout();
                }, null);

                mainTask["LAYOUT"].MarkComplete();
                context.ReportProgress(new BackgroundTaskProgress(mainTask.IntPercent, string.Format(SR.MessageDone, mainTask.Progress)));

                context.Complete();
            }
            catch (BackgroundTaskCancelledException)
            {
                context.Cancel();
            }
            catch (Exception ex)
            {
                context.Error(ex);
            }
        }
            public void Dispose()
            {
                if (_imageSets != null)
                {
                    foreach (IImageSet imageSet in _imageSets)
                    {
                        imageSet.Dispose();
                    }
                    _imageSets.Clear();
                    _imageSets = null;
                }

                _mprViewer = null;
            }
Exemplo n.º 3
0
        public void LaunchMpr()
        {
            Exception exception = null;

            IPresentationImage currentImage = this.Context.Viewer.SelectedPresentationImage;

            if (currentImage == null)
            {
                return;
            }

            // gather the source frames which MPR will operate on. exceptions are reported.
            BackgroundTaskParams @params;

            try
            {
                @params = new BackgroundTaskParams(FilterSourceFrames(currentImage.ParentDisplaySet, currentImage));
            }
            catch (Exception ex)
            {
                ExceptionHandler.Report(ex, SR.ExceptionMprLoadFailure, base.Context.DesktopWindow);
                return;
            }

            // execute the task to create an MPR component. exceptions (either thrown or passed via task) are reported, but any created component must be disposed
            BackgroundTask task = new BackgroundTask(LoadVolume, true, @params);

            task.Terminated += (sender, e) => exception = e.Exception;
            try
            {
                ProgressDialog.Show(task, base.Context.DesktopWindow, true, ProgressBarStyle.Blocks);
            }
            catch (Exception ex)
            {
                exception = ex;
                if (_viewer != null)
                {
                    _viewer.Dispose();
                    _viewer = null;
                }
            }
            finally
            {
                task.Dispose();
            }

            if (exception != null)
            {
                ExceptionHandler.Report(exception, SR.ExceptionMprLoadFailure, base.Context.DesktopWindow);
                return;
            }

            // launch the created MPR component as a workspace. any exceptions here are just reported.
            try
            {
                LaunchImageViewerArgs args = new LaunchImageViewerArgs(ViewerLaunchSettings.WindowBehaviour);
                args.Title = _viewer.Title;
                MprViewerComponent.Launch(_viewer, args);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Report(ex, SR.ExceptionMprLoadFailure, base.Context.DesktopWindow);
            }
            finally
            {
                _viewer = null;
            }
        }
 public BasicMprWorkspace(MprViewerComponent mprViewer)
 {
     _mprViewer = mprViewer;
 }