Пример #1
0
		public void Launch()
		{
			if (base.SelectedItems == null || base.SelectedItems.Count == 0)
				return;

			int n = 0;
			string[] selection = new string[base.SelectedItems.Count];
			foreach (IStudyItem item in base.SelectedItems)
			{
				if (!string.IsNullOrEmpty(item.Filename))
					selection[n++] = item.Filename;
			}

			bool cancelled = true;
			ImageViewerComponent viewer = new ImageViewerComponent();
			try
			{
				viewer.LoadImages(selection, base.Context.DesktopWindow, out cancelled);
			}
			catch (Exception ex)
			{
				base.DesktopWindow.ShowMessageBox(ex.Message, MessageBoxActions.Ok);
			}

			if (cancelled)
			{
				viewer.Dispose();
				return;
			}

			try
			{
				LaunchImageViewerArgs launchArgs = new LaunchImageViewerArgs(WindowBehaviour.Auto);
				ImageViewerComponent.Launch(viewer, launchArgs);
			}
			catch (Exception ex)
			{
				base.DesktopWindow.ShowMessageBox(ex.Message, MessageBoxActions.Ok);
				Platform.Log(LogLevel.Error, ex, "ImageViewerComponent launch failure.");
			}
		}
Пример #2
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;
			}
		}
Пример #3
0
		private ImageViewerComponent LoadAndOpenStudies()
		{
			var codeClock = new CodeClock();
			codeClock.Start();

			var viewer = CreateViewer(LoadPriors);
			var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow;

			try
			{
				viewer.LoadStudies(_studiesToOpen);
			}
			catch (Exception e)
			{
				ExceptionHandler.Report(e, SR.MessageFailedToOpenStudy, desktopWindow);
			}

			if (!AnySopsLoaded(viewer) && !AllowEmptyViewer)
			{
				viewer.Dispose();
				return null;
			}

			var args = new LaunchImageViewerArgs(WindowBehaviour) {Title = Title};
			ImageViewerComponent.Launch(viewer, args);

			codeClock.Stop();
			Platform.Log(LogLevel.Debug, string.Format("TTFI: {0}", codeClock));

			return viewer;
		}
Пример #4
0
		private ImageViewerComponent LoadAndOpenFiles()
		{
			var codeClock = new CodeClock();
			codeClock.Start();

			var viewer = CreateViewer(false); // don't find priors for files loaded off the local disk.
			var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow;

			try
			{
			    UserCancelled = false;
			    bool cancelled;
                viewer.LoadImages(_filenames.ToArray(), desktopWindow, out cancelled);
                UserCancelled = cancelled;
			}
			catch (Exception e)
			{
                if (!HandleErrors)
                    throw;
            
                ExceptionHandler.Report(e, SR.MessageFailedToOpenImages, desktopWindow);
			}

            if (UserCancelled || (!AnySopsLoaded(viewer) && !AllowEmptyViewer))
			{
				viewer.Dispose();
				return null;
			}

			var args = new LaunchImageViewerArgs(WindowBehaviour) {Title = Title};
			ImageViewerComponent.Launch(viewer, args);

			codeClock.Stop();
			Platform.Log(LogLevel.Debug, string.Format("TTFI: {0}", codeClock));

			return viewer;
		}
Пример #5
0
		private ImageViewerComponent LoadAndOpenStudies()
		{
			var codeClock = new CodeClock();
			codeClock.Start();

			var viewer = CreateViewer(LoadPriors);
			var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow;

			try
			{
				viewer.LoadStudies(_studiesToOpen);
			}
            catch(InUseLoadStudyException)
            {
                if (!HandleStudyInUseError(viewer))
                {
                    viewer.Dispose();
                    return null;
                }
            }
            catch(LoadMultipleStudiesException ex)
            {
                // Note: although there may be other errors, we only need to handle exceptions caused by study being processed.
                // Other errors will (probably) happen again when all studies are reloaded and will be handled in HandleStudyInUseError.
                if (ex.InUseCount > 0)
                {
                    if (!HandleStudyInUseError(viewer))
                    {
                        viewer.Dispose();
                        return null;
                    }
                }
                else
                {
                    ExceptionHandler.Report(ex, SR.MessageFailedToOpenStudy, desktopWindow);
                }
            }
			catch (Exception e)
			{
				ExceptionHandler.Report(e, SR.MessageFailedToOpenStudy, desktopWindow);
			}

			if (!AnySopsLoaded(viewer) && !AllowEmptyViewer)
			{
				viewer.Dispose();
				return null;
			}

			var args = new LaunchImageViewerArgs(WindowBehaviour) {Title = Title};
			ImageViewerComponent.Launch(viewer, args);

			codeClock.Stop(); // note: the time will be skewed if the workstation prompts users for action
			Platform.Log(LogLevel.Debug, string.Format("TTFI: {0}", codeClock));

			return viewer;
		}