private static void UpdateDisplayedImages(string loginName)
 {
     foreach (var desktopWindow in Application.DesktopWindows)
     {
         foreach (var workspace in desktopWindow.Workspaces)
         {
             var imageViewer = ImageViewerComponent.GetAsImageViewer(workspace);
             if (imageViewer != null)
             {
                 foreach (ImageBox imageBox in imageViewer.PhysicalWorkspace.ImageBoxes)
                 {
                     foreach (Tile tile in imageBox.Tiles)
                     {
                         var graphicsProvider = tile.PresentationImage as IOverlayGraphicsProvider;
                         if (graphicsProvider != null)
                         {
                             foreach (var graphic in graphicsProvider.OverlayGraphics)
                             {
                                 var aimGraphic = graphic as AimGraphic;
                                 if (aimGraphic != null &&
                                     (string.IsNullOrEmpty(loginName) || string.Equals(loginName, aimGraphic.UserLoginName, StringComparison.InvariantCultureIgnoreCase)))
                                 {
                                     tile.PresentationImage.Draw();
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the cursor token associated with the tool.
        /// </summary>
        /// <param name="point">The point in destination (view) coordinates.</param>
        /// <returns>a <see cref="CursorToken"/> object that is used to construct the cursor in the view.</returns>
        public bool GetCheckedSync()
        {
            ImageViewerComponent view = this.ImageViewer as ImageViewerComponent;
            ActionModelNode      node = view.ToolbarModel;

            ActionModelNode tempNode = null;

            IAction[] action = null;
            foreach (ActionModelNode tempnode in node.ChildNodes)
            {
                if (tempnode.PathSegment.ResourceKey == "ToolbarSynchronizeStackingLinkStudies")
                {
                    tempNode = tempnode;
                    break;
                }
            }
            if (tempNode != null)
            {
                action = tempNode.GetActionsInOrder();
            }
            if ((action != null))
            {
                ButtonAction ac = action[0] as ButtonAction;
                return(ac.Checked);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public void OpenStudy()
        {
            try
            {
                int numberOfSelectedStudies = Context.SelectedStudies.Count;
                if (Context.SelectedStudies.Count == 0)
                {
                    return;
                }

                if (!PermissionsHelper.IsInRole(ImageViewer.AuthorityTokens.Study.Open))
                {
                    Context.DesktopWindow.ShowMessageBox(SR.MessageOpenStudyPermissionDenied, MessageBoxActions.Ok);
                    return;
                }

                int numberOfLoadableStudies = GetNumberOfLoadableStudies();
                if (numberOfLoadableStudies != numberOfSelectedStudies)
                {
                    int    numberOfNonLoadableStudies = numberOfSelectedStudies - numberOfLoadableStudies;
                    string message;
                    if (numberOfSelectedStudies == 1)
                    {
                        message = SR.MessageCannotOpenNonStreamingStudy;
                    }
                    else
                    {
                        if (numberOfNonLoadableStudies == 1)
                        {
                            message = SR.MessageOneNonStreamingStudyCannotBeOpened;
                        }
                        else
                        {
                            message = String.Format(SR.MessageFormatXNonStreamingStudiesCannotBeOpened, numberOfNonLoadableStudies);
                        }
                    }

                    Context.DesktopWindow.ShowMessageBox(message, MessageBoxActions.Ok);
                    return;
                }

                var helper = new OpenStudyHelper
                {
                    WindowBehaviour  = ViewerLaunchSettings.WindowBehaviour,
                    AllowEmptyViewer = ViewerLaunchSettings.AllowEmptyViewer
                };

                foreach (var study in Context.SelectedStudies)
                {
                    helper.AddStudy(study.StudyInstanceUid, study.Server);
                }

                helper.Title = ImageViewerComponent.CreateTitle(GetSelectedPatients());
                helper.OpenStudies();
            }
            catch (Exception e)
            {
                ExceptionHandler.Report(e, Context.DesktopWindow);
            }
        }
Ejemplo n.º 4
0
        public override void Initialize()
        {
            base.Initialize();

            object[] tools;

            try
            {
                tools = new MeasurementToolbarToolExtensionPoint().CreateExtensions();
            }
            catch (NotSupportedException)
            {
                tools = new object[0];
                Platform.Log(LogLevel.Debug, "No clipboard toolbar drop-down items found.");
            }
            catch (Exception e)
            {
                tools = new object[0];
                Platform.Log(LogLevel.Debug, "Failed to create clipboard toolbar drop-down items.", e);
            }

            _toolSet = new ToolSet(tools, new ToolContextProxy(Context));
            //should register
            ImageViewerComponent viewer = Context.Viewer as ImageViewerComponent;

            viewer.RegisterImageViewerTool(_toolSet);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_parentForm != null)
                {
                    _parentForm.Move -= OnParentMoved;
                    _parentForm       = null;
                }

                if (_component != null)
                {
                    _component.Closing -= OnComponentClosing;
                    _component          = null;
                }

                if (_delayedEventPublisher != null)
                {
                    _delayedEventPublisher.Dispose();
                    _delayedEventPublisher = null;
                }

                if (_physicalWorkspace != null)
                {
                    _physicalWorkspace.Drawing                -= OnPhysicalWorkspaceDrawing;
                    _physicalWorkspace.LayoutCompleted        -= OnLayoutCompleted;
                    _physicalWorkspace.ScreenRectangleChanged -= OnScreenRectangleChanged;

                    _physicalWorkspace = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handle the situation where at least one of the study being loaded is in use. User can decide to continue loading or cancel the operation.
        /// In former case, all studies will be reloaded. Caller should check the value returned by this method.
        /// </summary>
        /// <param name="viewer"></param>
        /// <returns>False if the operation should be aborted. Caller is responsible for releasing any resource used by the <see cref="ImageViewerComponent"/>.</returns>
        private bool HandleStudyInUseError(ImageViewerComponent viewer)
        {
            var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow;
            var action        = PromptUser();

            switch (action)
            {
            case StudyInUseUserDecision.Continue:
                try
                {
                    SetStudyLoadOption(true);
                    viewer.LoadStudies(_studiesToOpen);
                    return(true);
                }
                catch (Exception e)
                {
                    ExceptionHandler.Report(e, SR.MessageFailedToOpenStudy, desktopWindow);
                }
                return(false);

            case StudyInUseUserDecision.Cancel:
                return(false);

            default:
                throw new NotImplementedException("Implement this action based on user's decision");
            }
        }
Ejemplo n.º 7
0
		public void SelectDisplaySet()
		{
			IDisplaySet displaySet1 = new DisplaySet();
			displaySet1.PresentationImages.Add(new TestPresentationImage());
			displaySet1.PresentationImages.Add(new TestPresentationImage());
			displaySet1.PresentationImages.Add(new TestPresentationImage());
			displaySet1.PresentationImages.Add(new TestPresentationImage());

			IDisplaySet displaySet2 = new DisplaySet();
			displaySet2.PresentationImages.Add(new TestPresentationImage());
			displaySet2.PresentationImages.Add(new TestPresentationImage());

			IImageViewer viewer = new ImageViewerComponent();
			IImageBox imageBox = new ImageBox();
			viewer.PhysicalWorkspace.ImageBoxes.Add(imageBox);

			imageBox.SetTileGrid(2, 2);
			imageBox.DisplaySet = displaySet1;
			imageBox[0, 0].Select();

			Assert.IsTrue(imageBox[0, 0].Selected);
			Assert.IsFalse(imageBox[0, 1].Selected);

			imageBox[0, 1].Select();
			Assert.IsFalse(imageBox[0, 0].Selected);
			Assert.IsTrue(imageBox[0, 1].Selected);

			imageBox.DisplaySet = displaySet2;
			Assert.IsFalse(imageBox[0, 0].Selected);
			Assert.IsTrue(imageBox[0, 1].Selected);
		}
Ejemplo n.º 8
0
        public void OpenStudies()
        {
            try
            {
                int numberOfSelectedStudies = Context.Component.Selection.Items.Length;

                if (numberOfSelectedStudies == 0)
                {
                    return;
                }

                var helper = new OpenStudyHelper
                {
                    WindowBehaviour  = ViewerLaunchSettings.WindowBehaviour,
                    AllowEmptyViewer = ViewerLaunchSettings.AllowEmptyViewer
                };

                foreach (StudyItem study in Context.Component.Selection.Items)
                {
                    helper.AddStudy(study.StudyInstanceUid, study.Server);
                }

                helper.Title = ImageViewerComponent.CreateTitle(GetSelectedPatients());
                helper.OpenStudies();
            }
            catch (Exception e)
            {
                ExceptionHandler.Report(e, Context.DesktopWindow);
            }
        }
        public void ReplaceDisplaySet()
        {
            IDisplaySet        displaySet1 = new DisplaySet();
            IPresentationImage image1      = new TestPresentationImage();

            displaySet1.PresentationImages.Add(image1);

            IDisplaySet        displaySet2 = new DisplaySet();
            IPresentationImage image2      = new TestPresentationImage();

            displaySet2.PresentationImages.Add(image2);

            ImageViewerComponent viewer = new ImageViewerComponent();

            IImageBox imageBox1 = new ImageBox();

            viewer.PhysicalWorkspace.ImageBoxes.Add(imageBox1);

            imageBox1.SetTileGrid(2, 2);
            imageBox1.DisplaySet = displaySet1;
            imageBox1[0, 0].Select();

            Assert.IsTrue(displaySet1.Selected);
            Assert.IsTrue(image1.Selected);

            imageBox1.DisplaySet = displaySet2;

            Assert.IsFalse(displaySet1.Selected);
            Assert.IsFalse(image1.Selected);

            Assert.IsTrue(displaySet2.Selected);
            Assert.IsTrue(image2.Selected);
        }
Ejemplo n.º 10
0
        public void AddDuplicateImage()
        {
            IImageViewer viewer    = new ImageViewerComponent();
            StudyTree    studyTree = viewer.StudyTree;

            string studyUid1  = DicomUid.GenerateUid().UID;
            string seriesUid1 = DicomUid.GenerateUid().UID;
            string imageUid1  = DicomUid.GenerateUid().UID;

            ImageSop image1 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);
            ImageSop image2 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);

            //The sop has already silently disposed the 2nd data source.
            Assert.IsTrue(ReferenceEquals(image1.DataSource, image2.DataSource));
            studyTree.AddSop(image1);
            studyTree.AddSop(image2);

            Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid1].Sops.Count == 1);

            TestDataSource dataSource = (TestDataSource)image1.DataSource;

            viewer.Dispose();

            Assert.IsTrue(dataSource.IsDisposed);
        }
        public void SelectDisplaySet()
        {
            IDisplaySet displaySet1 = new DisplaySet();

            displaySet1.PresentationImages.Add(new TestPresentationImage());
            displaySet1.PresentationImages.Add(new TestPresentationImage());
            displaySet1.PresentationImages.Add(new TestPresentationImage());
            displaySet1.PresentationImages.Add(new TestPresentationImage());

            IDisplaySet displaySet2 = new DisplaySet();

            displaySet2.PresentationImages.Add(new TestPresentationImage());
            displaySet2.PresentationImages.Add(new TestPresentationImage());

            IImageViewer viewer   = new ImageViewerComponent();
            IImageBox    imageBox = new ImageBox();

            viewer.PhysicalWorkspace.ImageBoxes.Add(imageBox);

            imageBox.SetTileGrid(2, 2);
            imageBox.DisplaySet = displaySet1;
            imageBox[0, 0].Select();

            Assert.IsTrue(imageBox[0, 0].Selected);
            Assert.IsFalse(imageBox[0, 1].Selected);

            imageBox[0, 1].Select();
            Assert.IsFalse(imageBox[0, 0].Selected);
            Assert.IsTrue(imageBox[0, 1].Selected);

            imageBox.DisplaySet = displaySet2;
            Assert.IsFalse(imageBox[0, 0].Selected);
            Assert.IsTrue(imageBox[0, 1].Selected);
        }
        /// <summary>
        /// Loads tag data for the study in the specified workspace.
        /// </summary>
        /// <param name="workspace"></param>
        private void LoadData(Workspace workspace)
        {
            IImageViewer viewer = workspace == null ? null : ImageViewerComponent.GetAsImageViewer(workspace);

            if (viewer != null)
            {
                // for simplicity, assume only one patient and study in the workspace
                Patient patient = CollectionUtils.FirstElement(viewer.StudyTree.Patients.Values);
                _activeStudy = CollectionUtils.FirstElement(patient.Studies.Values);

                // load the tags for the active study, remembering the original value so we know if any changes are made
                _originalTags = _tags = MakeTagsString(_database.GetTagsForStudy(_activeStudy.StudyInstanceUID));

                if (!_searchEnabled)
                {
                    FindSimilar();
                }
            }
            else
            {
                Clear();
            }

            NotifyPropertyChanged("Tags");
            NotifyPropertyChanged("UpdateEnabled");
        }
Ejemplo n.º 13
0
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_parentForm != null)
				{
					_parentForm.Move -= OnParentMoved;
					_parentForm = null;
				}

				if (_component != null)
				{
					_component.Closing -= OnComponentClosing;
					_component = null;
				}

				if (_delayedEventPublisher != null)
				{
					_delayedEventPublisher.Dispose();
					_delayedEventPublisher = null;
				}

				if (_physicalWorkspace != null)
				{
					_physicalWorkspace.Drawing -= OnPhysicalWorkspaceDrawing;
					_physicalWorkspace.LayoutCompleted -= OnLayoutCompleted;
					_physicalWorkspace.ScreenRectangleChanged -= OnScreenRectangleChanged;

					_physicalWorkspace = null;
				}
			}

			base.Dispose(disposing);
		}
Ejemplo n.º 14
0
		public void ReplaceDisplaySet()
		{
			IDisplaySet displaySet1 = new DisplaySet();
			IPresentationImage image1 = new TestPresentationImage();
			displaySet1.PresentationImages.Add(image1);

			IDisplaySet displaySet2 = new DisplaySet();
			IPresentationImage image2 = new TestPresentationImage();
			displaySet2.PresentationImages.Add(image2);

			ImageViewerComponent viewer = new ImageViewerComponent();

			IImageBox imageBox1 = new ImageBox();
			viewer.PhysicalWorkspace.ImageBoxes.Add(imageBox1);

			imageBox1.SetTileGrid(2, 2);
			imageBox1.DisplaySet = displaySet1;
			imageBox1[0,0].Select();

			Assert.IsTrue(displaySet1.Selected);
			Assert.IsTrue(image1.Selected);

			imageBox1.DisplaySet = displaySet2;

			Assert.IsFalse(displaySet1.Selected);
			Assert.IsFalse(image1.Selected);

			Assert.IsTrue(displaySet2.Selected);
			Assert.IsTrue(image2.Selected);

		}
        private static Dictionary <string, Color> GetDisplayedUsersAndMarkupColors()
        {
            var displayedUserColors = new Dictionary <string, Color>();
            var imageViewer         = ImageViewerComponent.GetAsImageViewer(Application.ActiveDesktopWindow.ActiveWorkspace);

            if (imageViewer != null)
            {
                foreach (ImageBox imageBox in imageViewer.PhysicalWorkspace.ImageBoxes)
                {
                    foreach (Tile tile in imageBox.Tiles)
                    {
                        var graphicsProvider = tile.PresentationImage as IOverlayGraphicsProvider;
                        if (graphicsProvider != null)
                        {
                            foreach (var graphic in graphicsProvider.OverlayGraphics)
                            {
                                var aimGraphic = graphic as AimGraphic;
                                if (aimGraphic != null)
                                {
                                    if (!displayedUserColors.ContainsKey(aimGraphic.UserLoginName))
                                    {
                                        displayedUserColors[aimGraphic.UserLoginName] = aimGraphic.Color;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(displayedUserColors);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates the <see cref="ImageViewerComponent"/>, loads the specified images,
        /// and launches the <see cref="ImageViewerComponent"/>.
        /// </summary>
        public ImageViewerComponent OpenFiles()
        {
            ImageViewerComponent viewer = null;

            BlockingOperation.Run(delegate { viewer = LoadAndOpenFiles(); });
            return(viewer);
        }
Ejemplo n.º 17
0
        private static IImageViewer LaunchViewer(OpenStudiesRequest request, string primaryStudyInstanceUid)
        {
            try
            {
                CompleteOpenStudyInfo(request.StudiesToOpen);
            }
            catch (Exception ex)
            {
                if (request.ReportFaultToUser)
                {
                    SynchronizationContext.Current.Post(ReportLoadFailures, ex);
                }
                throw;
            }

            ImageViewerComponent viewer;

            if (!request.LoadPriors.HasValue || request.LoadPriors.Value)
            {
                viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended);
            }
            else
            {
                viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended, PriorStudyFinder.Null);
            }

            var loadStudyArgs = (from info in request.StudiesToOpen
                                 let server = ServerDirectory.GetRemoteServersByAETitle(info.SourceAETitle).FirstOrDefault() ?? ServerDirectory.GetLocalServer()
                                              select new LoadStudyArgs(info.StudyInstanceUid, server)).ToList();

            try
            {
                viewer.LoadStudies(loadStudyArgs);
            }
            catch (Exception e)
            {
                bool faultThrown = false;
                try
                {
                    HandleLoadStudiesException(e, primaryStudyInstanceUid, viewer);
                }
                catch
                {
                    faultThrown = true;
                    viewer.Dispose();
                    throw;
                }
                finally
                {
                    if (!faultThrown || request.ReportFaultToUser)
                    {
                        SynchronizationContext.Current.Post(ReportLoadFailures, e);
                    }
                }
            }

            ImageViewerComponent.Launch(viewer, new LaunchImageViewerArgs(ViewerLaunchSettings.WindowBehaviour));
            return(viewer);
        }
Ejemplo n.º 18
0
        private void NewToolSet()
        {
            _viewer  = new ImageViewerComponent();
            _context = new TestToolContext(_viewer);
            _toolSet = new ToolSet(CreateTools(), _context);

            MouseToolSettingsProfile.Reset();
        }
Ejemplo n.º 19
0
        public ImageViewerComponent OpenFiles()
        {
            string strPatientName       = "";
            ImageViewerComponent viewer = null;

            BlockingOperation.Run(delegate { viewer = LoadAndOpenFiles(strPatientName); });
            return(viewer);
        }
Ejemplo n.º 20
0
        public OpenStudiesResult OpenStudies(OpenStudiesRequest request)
        {
            if (request == null)
            {
                string message = "The open studies request cannot be null.";
                Platform.Log(LogLevel.Debug, message);
                throw new FaultException(message);
            }

            if (request.StudiesToOpen == null || request.StudiesToOpen.Count == 0)
            {
                string message = "At least one study must be specified.";
                Platform.Log(LogLevel.Debug, message);
                throw new FaultException(message);
            }

            OpenStudiesResult result = new OpenStudiesResult();
            bool activateIfOpen      = request.ActivateIfAlreadyOpen ?? true;

            try
            {
                string       primaryStudyInstanceUid = request.StudiesToOpen[0].StudyInstanceUid;
                IImageViewer viewer = null;
                if (activateIfOpen)
                {
                    Workspace workspace = GetViewerWorkspace(primaryStudyInstanceUid);
                    if (workspace != null)
                    {
                        viewer = ImageViewerComponent.GetAsImageViewer(workspace);
                        workspace.Activate();
                    }
                }

                if (viewer == null)
                {
                    viewer = LaunchViewer(request, primaryStudyInstanceUid);
                }

                Guid?viewerId = ViewerAutomationTool.GetViewerId(viewer);
                if (viewerId == null)
                {
                    throw new FaultException("Failed to retrieve the id of the specified viewer.");
                }

                result.Viewer = new Viewer(viewerId.Value, GetPrimaryStudyIdentifier(viewer));
                return(result);
            }
            catch (FaultException)
            {
                throw;
            }
            catch (Exception e)
            {
                string message = "An unexpected error has occurred while attempting to open the study(s).";
                Platform.Log(LogLevel.Error, e, message);
                throw new FaultException(message);
            }
        }
Ejemplo n.º 21
0
			private SingleStudyLoader(SynchronizationContext uiThreadContext, ImageViewerComponent viewer)
			{
				Platform.CheckForNullReference(uiThreadContext, "uiThreadContext");

				IsValidPrior = false;
				_uiThreadContext = uiThreadContext;
				_viewer = viewer;
				LoadOnlineOnly = false;
			}
        public override void SetModelObject(object modelObject)
        {
            _viewer = (ImageViewerComponent)modelObject;
            _viewer.PhysicalWorkspace.LayoutCompleted     += OnLayoutCompleted;
            _viewer.PhysicalWorkspace.Drawing             += OnPhysicalWorkspaceDrawing;
            _viewer.EventBroker.PresentationImageSelected += OnPresentationImageSelected;

            UpdateActionModel(false);
            RefreshImageBoxHandlers(false);
        }
Ejemplo n.º 23
0
        private void OnWorkspaceChanged(object sender, ItemEventArgs <Workspace> e)
        {
            IImageViewer viewer = null;

            if (_desktopWindow.ActiveWorkspace != null)
            {
                viewer = ImageViewerComponent.GetAsImageViewer(_desktopWindow.ActiveWorkspace);
            }

            SetActiveViewer(viewer);
        }
Ejemplo n.º 24
0
        private static IImageViewer CastToImageViewer(Workspace workspace)
        {
            IImageViewer viewer = null;

            if (workspace != null)
            {
                viewer = ImageViewerComponent.GetAsImageViewer(workspace);
            }

            return(viewer);
        }
        public void TestProcessMessage()
        {
            try
            {
                Assert.IsNotNull(SynchronizationContext.Current, "SynchronizationContext.Current");

                DicomFile file = new DicomFile("TileEntityHandlerTest.dcm");
                DicomAttributeCollection dataSet = file.DataSet;
                SetupSecondaryCapture(dataSet);
                file.Save();


                ImageViewerComponent viewer = new ImageViewerComponent();
                viewer.Start();

                viewer.LoadImages(new[] { "TileEntityHandlerTest.dcm" });

                ManualResetEvent signal = new ManualResetEvent(false);
                viewer.EventBroker.LayoutManagerCompleted += (s, e) => signal.Set();

                viewer.Layout();
                Console.WriteLine("Waiting for layout to complete");
                if (!signal.WaitOne(20000))
                {
                    Assert.Fail("Abort: something is not working properly.");
                }

                Console.WriteLine("Layout completed");
                Assert.IsNotNull(viewer.PhysicalWorkspace);
                Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0]);
                Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0]);

                Tile tile = viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0] as Tile;

                Assert.IsNotNull(tile.PresentationImage);

                MockApplicationContext context = new MockApplicationContext();

                TileEntityHandler handler = new TileEntityHandler {
                    ApplicationContext = context
                };
                handler.SetModelObject(tile);
                ChangeClientRectangle(context, handler, 0, 0, 512, 512, "Case: Size is even");
                ChangeClientRectangle(context, handler, 0, 0, 311, 311, "Case: Size is odd");
                ChangeClientRectangle(context, handler, 10, 10, 300, 301, "Case: Left,Top are positive");
                ChangeClientRectangle(context, handler, -10, -10, 512, 512, "Case: Left,Top are negative");
            }
            finally
            {
                File.Delete("TileEntityHandlerTest.dcm");
            }
        }
Ejemplo n.º 26
0
        protected override void Layout()
        {
            base.Layout();
            baseBounds = Bounds;
            thisBounds = GH_Convert.ToRectangle(Bounds);
            //Ref
            ImageViewerComponent component = Owner as ImageViewerComponent;
            //Bounds
            int buttonHorizontalResolution = component.resolution.Length * 6 + 6;
            int buttonHorizontalDPI        = component.dpi.Length * 6 + 6;
            int buttonHorizontalRatio      = component.ratio.Length * 6 + 6;

            buttonBounds = new RectangleF(new PointF(baseBounds.Right + 10, this.Bounds.Top),
                                          new SizeF(buttonHorizontalResolution, baseBounds.Height));
            buttonBounds.Inflate(0, -5);

            dpiBounds = new RectangleF(new PointF(buttonBounds.Right + 5, baseBounds.Top),
                                       new SizeF(buttonHorizontalDPI, baseBounds.Height));
            dpiBounds.Inflate(0, -5);

            ratioBounds = new RectangleF(new PointF(dpiBounds.Right + 5, baseBounds.Top),
                                         new SizeF(buttonHorizontalRatio, baseBounds.Height));
            ratioBounds.Inflate(0, -5);

            ////////////////////////////////////////////////////////////////////////////

            SizeF minSize = new SizeF();

            if (component.m_Size.Width < 200)
            {
                minSize = new SizeF(200, 200);
            }
            else
            {
                minSize = component.m_Size;
            }

            imgBounds = new RectangleF(new PointF(baseBounds.Left + 10, baseBounds.Bottom),
                                       minSize);

            backButton = new RectangleF(imgBounds.Location, imgBounds.Size);
            backButton.Inflate(5, 5);

            thisBounds         = RectangleF.Union(thisBounds, buttonBounds);
            thisBounds         = RectangleF.Union(thisBounds, dpiBounds);
            thisBounds         = RectangleF.Union(thisBounds, backButton);
            thisBounds         = RectangleF.Union(thisBounds, ratioBounds);
            thisBounds.Width  += 5;
            thisBounds.Height += 5;

            Bounds = thisBounds;
        }
Ejemplo n.º 27
0
        private static Workspace GetViewerWorkspace(string primaryStudyUid)
        {
            foreach (Workspace workspace in GetViewerWorkspaces())
            {
                IImageViewer viewer = ImageViewerComponent.GetAsImageViewer(workspace);
                if (primaryStudyUid == GetPrimaryStudyInstanceUid(viewer))
                {
                    return(workspace);
                }
            }

            return(null);
        }
Ejemplo n.º 28
0
        public CloseViewerOutput CloseViewer(CloseViewerInput input)
        {
            Platform.CheckForNullReference(input, "input");
            Platform.CheckMemberIsSet(input.ViewerId, "ViewerId");

            var viewer    = _viewers[(int)input.ViewerId];
            var workspace = Application.ActiveDesktopWindow.Workspaces
                            .First(w => ImageViewerComponent.GetAsImageViewer(w) == viewer);

            workspace.Close(UserInteraction.NotAllowed);

            return(new CloseViewerOutput());
        }
Ejemplo n.º 29
0
        private static Workspace GetViewerWorkspace(IImageViewer viewer)
        {
            foreach (Workspace workspace in GetViewerWorkspaces())
            {
                IImageViewer workspaceViewer = ImageViewerComponent.GetAsImageViewer(workspace);
                if (viewer == workspaceViewer)
                {
                    return(workspace);
                }
            }

            return(null);
        }
Ejemplo n.º 30
0
        public void TestProcessMessage()
        {
            
            try
            {

                Assert.IsNotNull(SynchronizationContext.Current, "SynchronizationContext.Current");
                
                DicomFile file = new DicomFile("TileEntityHandlerTest.dcm");
                DicomAttributeCollection dataSet = file.DataSet;
                SetupSecondaryCapture(dataSet);
                file.Save();

                
                ImageViewerComponent viewer = new ImageViewerComponent();
                viewer.Start();

                viewer.LoadImages(new[] { "TileEntityHandlerTest.dcm" });

                ManualResetEvent signal = new ManualResetEvent(false);
                viewer.EventBroker.LayoutManagerCompleted += (s, e) => signal.Set();

                viewer.Layout();
                Console.WriteLine("Waiting for layout to complete");
                if (!signal.WaitOne(20000))
                    Assert.Fail("Abort: something is not working properly.");

                Console.WriteLine("Layout completed");
                Assert.IsNotNull(viewer.PhysicalWorkspace);
                Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0]);
                Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0]);

                Tile tile = viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0] as Tile;

                Assert.IsNotNull(tile.PresentationImage);

                MockApplicationContext context = new MockApplicationContext();

                TileEntityHandler handler = new TileEntityHandler { ApplicationContext = context };
                handler.SetModelObject(tile);
                ChangeClientRectangle(context, handler, 0, 0, 512, 512, "Case: Size is even");
                ChangeClientRectangle(context, handler, 0, 0, 311, 311, "Case: Size is odd");
                ChangeClientRectangle(context, handler, 10, 10, 300, 301, "Case: Left,Top are positive");
                ChangeClientRectangle(context, handler, -10, -10, 512, 512, "Case: Left,Top are negative");
                
            }
            finally
            {
                File.Delete("TileEntityHandlerTest.dcm");
            }
        }
Ejemplo n.º 31
0
 private static IEnumerable <Workspace> GetViewerWorkspaces()
 {
     foreach (DesktopWindow desktopWindow in Application.DesktopWindows)
     {
         foreach (Workspace workspace in desktopWindow.Workspaces)
         {
             IImageViewer viewer = ImageViewerComponent.GetAsImageViewer(workspace);
             if (viewer != null)
             {
                 yield return(workspace);
             }
         }
     }
 }
Ejemplo n.º 32
0
        private ImageViewerComponent LoadAndOpenFiles(string strPatientName)
        {
            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;

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

            try
            {
                UserCancelled = false;
                bool cancelled;
                viewer.LoadImages(_filenames.ToArray(), desktopWindow, out cancelled, strPatientName);
                UserCancelled = cancelled;
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e.ToString());

                //if (!HandleErrors)
                //    throw;

                //ExceptionHandler.Report(e, SR.MessageFailedToOpenImages, desktopWindow);
            }

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

            var args = new LaunchImageViewerArgs(WindowBehaviour)
            {
                Title = "imageview"
            };

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

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

            return(viewer);
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing && _viewer != null)
            {
                _viewer.PhysicalWorkspace.LayoutCompleted     -= OnLayoutCompleted;
                _viewer.PhysicalWorkspace.Drawing             -= OnPhysicalWorkspaceDrawing;
                _viewer.EventBroker.PresentationImageSelected -= OnPresentationImageSelected;

                DisposeActionHandlers();
                DisposeImageBoxHandlers();

                _viewer = null;
            }
        }
Ejemplo n.º 34
0
        protected override void OnStop()
        {
            if (_viewerHandler != null)
            {
                _viewerHandler.Dispose();
                _viewerHandler = null;
            }

            //TODO (CR May 2010): WebDesktopWindow shouldn't hang around, but we can check.
            if (_viewer != null)
            {
                _viewer.Stop();
                _viewer.Dispose();
                _viewer = null;
            }
        }
Ejemplo n.º 35
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.");
            }
        }
Ejemplo n.º 36
0
		internal ImageViewerControl(ImageViewerComponent component)
		{
			_component = component;
			_physicalWorkspace = _component.PhysicalWorkspace as PhysicalWorkspace;
			InitializeComponent();

			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

			this.BackColor = Color.Black;

			_component.Closing += new EventHandler(OnComponentClosing);
			_physicalWorkspace.Drawing += new EventHandler(OnPhysicalWorkspaceDrawing);
			_physicalWorkspace.LayoutCompleted += new EventHandler(OnLayoutCompleted);
			_physicalWorkspace.ScreenRectangleChanged += new EventHandler(OnScreenRectangleChanged);

			_delayedEventPublisher = new DelayedEventPublisher(OnRecalculateImageBoxes, 50);
		}
		public void LayoutImageBoxes()
		{
			IImageViewer viewer = new ImageViewerComponent();
			viewer.PhysicalWorkspace.SetImageBoxGrid(2, 1);

			IDisplaySet displaySet1 = new DisplaySet();
			IDisplaySet displaySet2 = new DisplaySet();
			PresentationImage image1 = new TestPresentationImage();
			PresentationImage image2 = new TestPresentationImage();
			displaySet1.PresentationImages.Add(image1);
			displaySet2.PresentationImages.Add(image2);

			viewer.PhysicalWorkspace.ImageBoxes[0].DisplaySet = displaySet1;
			viewer.PhysicalWorkspace.ImageBoxes[1].DisplaySet = displaySet2;
			viewer.PhysicalWorkspace.SetImageBoxGrid(1, 1);

			Assert.IsFalse(displaySet1.Visible);
			Assert.IsFalse(displaySet2.Visible);
		}
Ejemplo n.º 38
0
		internal ImageViewerControl(ImageViewerComponent component)
		{
			_component = component;
			_physicalWorkspace = (PhysicalWorkspace) _component.PhysicalWorkspace;

			SuspendLayout();
			Name = "ImageViewerControl";
			ResumeLayout(false);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);

			base.BackColor = Color.Black;

			_component.Closing += OnComponentClosing;
			_physicalWorkspace.Drawing += OnPhysicalWorkspaceDrawing;
			_physicalWorkspace.LayoutCompleted += OnLayoutCompleted;
			_physicalWorkspace.ScreenRectangleChanged += OnScreenRectangleChanged;

			_delayedEventPublisher = new DelayedEventPublisher(OnRecalculateImageBoxes, 50);
		}
Ejemplo n.º 39
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.");
			}
		}
Ejemplo n.º 40
0
		private static IImageViewer LaunchViewer(OpenStudiesRequest request, string primaryStudyInstanceUid)
		{
			try
			{
				CompleteOpenStudyInfo(request.StudiesToOpen);
			}
			catch (Exception ex)
			{
				if (request.ReportFaultToUser) SynchronizationContext.Current.Post(ReportLoadFailures, ex);
				throw;
			}
		    
            ImageViewerComponent viewer;
            if (!request.LoadPriors.HasValue || request.LoadPriors.Value)
                viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended);
            else
                viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended, PriorStudyFinder.Null);

			var loadStudyArgs = (from info in request.StudiesToOpen 
                                 let server = ServerDirectory.GetRemoteServersByAETitle(info.SourceAETitle).FirstOrDefault() ?? ServerDirectory.GetLocalServer()
                                 select new LoadStudyArgs(info.StudyInstanceUid, server)).ToList();

		    try
			{
				viewer.LoadStudies(loadStudyArgs);
			}
			catch (Exception e)
			{
				bool faultThrown = false;
				try
				{
					HandleLoadStudiesException(e, primaryStudyInstanceUid, viewer);
				}
				catch
				{
					faultThrown = true;
					viewer.Dispose();
					throw;
				}
				finally
				{
					if (!faultThrown || request.ReportFaultToUser)
						SynchronizationContext.Current.Post(ReportLoadFailures, e);
				}
			}

			ImageViewerComponent.Launch(viewer, new LaunchImageViewerArgs(ViewerLaunchSettings.WindowBehaviour));
			return viewer;
		}
Ejemplo n.º 41
0
	    protected override void OnStart(StartApplicationRequest request)
		{
			lock (_syncLock)
			{
                Platform.Log(LogLevel.Info, "Viewer Application is starting...");
                if (Application.Instance == null)
					Platform.StartApp("ClearCanvas.Desktop.Application",new string[] {"-r"});
			}

            


            if (Platform.IsLogLevelEnabled(LogLevel.Debug))
                Platform.Log(LogLevel.Debug, "Finding studies...");
			var startRequest = (StartViewerApplicationRequest)request;
			IList<StudyRootStudyIdentifier> studies = FindStudies(startRequest);

			List<LoadStudyArgs> loadArgs = CollectionUtils.Map(studies, (StudyRootStudyIdentifier identifier) => CreateLoadStudyArgs(identifier));

		    DesktopWindowCreationArgs args = new DesktopWindowCreationArgs("", Identifier.ToString());
            WebDesktopWindow window = new WebDesktopWindow(args, Application.Instance);
            window.Open();

            _viewer = CreateViewerComponent(startRequest);

			try
			{
                if (Platform.IsLogLevelEnabled(LogLevel.Debug))
                    Platform.Log(LogLevel.Debug, "Loading study...");
                _viewer.LoadStudies(loadArgs);
			}
			catch (Exception e)
			{
				if (!AnySopsLoaded(_viewer)) //end the app.
                    throw;

				//Show an error and continue.
				ExceptionHandler.Report(e, window);
			}

            if (Platform.IsLogLevelEnabled(LogLevel.Debug))
                Platform.Log(LogLevel.Info, "Launching viewer...");
			
			ImageViewerComponent.Launch(_viewer, window, "");

			_viewerHandler = EntityHandler.Create<ViewerEntityHandler>();
			_viewerHandler.SetModelObject(_viewer);
		    _app = new Common.ViewerApplication
		               {
		                   Identifier = Identifier,
		                   Viewer = (Viewer) _viewerHandler.GetEntity(),

                           VersionString = GetProductVersionString()
                                
			           };
            

            // Push the ViewerApplication object to the client
            Event @event = new PropertyChangedEvent
            {
                PropertyName = "Application",
                Value = _app,
                Identifier = Guid.NewGuid(),
                SenderId = request.Identifier
            };

            ApplicationContext.Current.FireEvent(@event);
		}
Ejemplo n.º 42
0
        /// <summary>
        /// Called by the framework when the user clicks the "apply" menu item or toolbar button.
        /// </summary>
        public void SeriesQuery()
        {

            string callingAE = ServerTree.GetClientAETitle();
            List<SeriesItem> SeriesList = new List<SeriesItem>();

            #region remote datastore
            // If remote data store, need to query server for series level information
            if (!this.Context.SelectedServerGroup.IsLocalDatastore)
            {
                // Loop through all selected servers
                foreach (Server node in this.Context.SelectedServerGroup.Servers)
                {
                    DicomAttributeCollection dicomAttributeCollection = new DicomAttributeCollection();
                    // Query on "Series" Level
                    dicomAttributeCollection[DicomTags.QueryRetrieveLevel].SetStringValue("SERIES");

                    string studyUID = this.Context.SelectedStudies[0].StudyInstanceUid;
                    dicomAttributeCollection[DicomTags.StudyInstanceUid].SetStringValue(studyUID);
                    dicomAttributeCollection[DicomTags.SeriesDescription].SetNullValue();
                    dicomAttributeCollection[DicomTags.SeriesInstanceUid].SetNullValue();
                    dicomAttributeCollection[DicomTags.SeriesNumber].SetNullValue();
                    dicomAttributeCollection[DicomTags.Modality].SetNullValue();
                    dicomAttributeCollection[DicomTags.Date].SetNullValue();
                    dicomAttributeCollection[DicomTags.Time].SetNullValue();
                    dicomAttributeCollection[DicomTags.RepetitionTime].SetNullValue();

                    IList<DicomAttributeCollection> resultsList;
                    StudyRootFindScu findScu = new StudyRootFindScu();
                    List<string> seriesUIDs = new List<string>();

                    resultsList = findScu.Find(
                                    callingAE,
                                    node.AETitle,
                                    node.Host,
                                    node.Port,
                                    dicomAttributeCollection);

                    findScu.CloseAssociation();
                    findScu.Dispose();

                    foreach (DicomAttributeCollection msg in resultsList)
                    {
                        string text = msg[DicomTags.SeriesInstanceUid];
                        Platform.Log(LogLevel.Info, text);

                        SeriesItem series = new SeriesItem();

                        series.SeriesNumber = msg[DicomTags.SeriesNumber];
                        series.SeriesDescription = msg[DicomTags.SeriesDescription];
                        series.StudyInstanceUID = msg[DicomTags.StudyInstanceUid];
                        series.SeriesInstanceUID = msg[DicomTags.SeriesInstanceUid];
                        series.Modality = msg[DicomTags.Modality];
                        series.Date = msg[DicomTags.Date];
                        series.Time = msg[DicomTags.Time];
                        //series.NumberOfSeriesRelatedInstances = int.Parse(msg[DicomTags.NumberOfSeriesRelatedInstances].ToString());
                        SeriesList.Add(series);

                    }
                    _component = new SeriesBrowserComponent(SeriesList, node);
                    _shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, "Series Browser", ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide);
                    _shelf.Closed += Shelf_Closed;
                }              
            }
            #endregion
           
            #region Local Datastore
            // If local datastore, can obtain series information by building study tree
            else
            {
                IImageViewer viewer = new ImageViewerComponent();
                StudyTree studyTree = viewer.StudyTree;

                // Add selected objects studies to study tree
                foreach (StudyItem selectedstudy in this.Context.SelectedStudies)
                {
                    string studyUID = selectedstudy.StudyInstanceUid;
                    int numberOfSops = LocalStudyLoader.Start(new StudyLoaderArgs(studyUID, null));
                    for (int i = 0; i < numberOfSops; ++i)
                    {
                        Sop imageSop = LocalStudyLoader.LoadNextSop();
                        studyTree.AddSop(imageSop);
                    }
                }

                foreach (Patient patient in studyTree.Patients)
                {
                    foreach (Study study in patient.Studies)
                    {
                        foreach (Series series in study.Series)
                        {
                            SeriesItem seriesitem = new SeriesItem();

                            seriesitem.SeriesNumber = series.SeriesNumber.ToString();
                            seriesitem.SeriesDescription = series.SeriesDescription;
                            seriesitem.StudyInstanceUID = study.StudyInstanceUid;
                            seriesitem.SeriesInstanceUID = series.SeriesInstanceUid;
                            seriesitem.Modality = series.Modality;
                            seriesitem.Date = series.SeriesDate;
                            seriesitem.Time = series.SeriesTime;
                            //series.NumberOfSeriesRelatedInstances = int.Parse(msg[DicomTags.NumberOfSeriesRelatedInstances].ToString());
                            seriesitem.NumberOfSeriesRelatedInstances = series.Sops.Count.ToString();

                            SeriesList.Add(seriesitem);
                        }
                    _component = new SeriesBrowserComponent(SeriesList, null);
                    _shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, DicomDataFormatHelper.PersonNameFormatter(patient.PatientsName), ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide);
                    _shelf.Closed += Shelf_Closed;
                    }
                }
            }
            #endregion

        }
Ejemplo n.º 43
0
        /// <summary>
        /// Handle the situation where at least one of the study being loaded is in use. User can decide to continue loading or cancel the operation.
        /// In former case, all studies will be reloaded. Caller should check the value returned by this method.
        /// </summary>
        /// <param name="viewer"></param>
        /// <returns>False if the operation should be aborted. Caller is responsible for releasing any resource used by the <see cref="ImageViewerComponent"/>.</returns>
        private bool HandleStudyInUseError(ImageViewerComponent viewer)
        {
            var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow;
            var action = PromptUser();
            switch (action)
            {
                case StudyInUseUserDecision.Continue:
                    try
                    {
                        SetStudyLoadOption(true);
                        viewer.LoadStudies(_studiesToOpen);
                        return true;
                    }
                    catch (Exception e)
                    {
                        ExceptionHandler.Report(e, SR.MessageFailedToOpenStudy, desktopWindow);
                    }
                    return false;

                case StudyInUseUserDecision.Cancel:
                    return false;

                default:
                    throw new NotImplementedException("Implement this action based on user's decision");
            }

        }
Ejemplo n.º 44
0
			/// <summary>
			/// Constructs a new <see cref="ImageViewerToolContext"/>.
			/// </summary>
			/// <param name="component">The <see cref="ImageViewerComponent"/> that owns the tools.</param>
			public ImageViewerToolContext(ImageViewerComponent component)
			{
				_component = component;
			}
Ejemplo n.º 45
0
			public SingleStudyLoader(SynchronizationContext uiThreadContext, ImageViewerComponent viewer, StudyItem studyItem)
				: this(uiThreadContext, viewer)
			{
				_studyItem = studyItem;
			}
Ejemplo n.º 46
0
		public ViewerShortcutManager(ImageViewerComponent viewer)
		{
			_tools = new Dictionary<ITool, ITool>();
			_viewer = viewer;
		}
Ejemplo n.º 47
0
		public void BuildStudyTree()
		{
			IImageViewer viewer = new ImageViewerComponent();
			StudyTree studyTree = viewer.StudyTree;

			string studyUid1 = DicomUid.GenerateUid().UID;
			string studyUid2 = DicomUid.GenerateUid().UID;
			string studyUid3 = DicomUid.GenerateUid().UID;

			string seriesUid1 = DicomUid.GenerateUid().UID;
			string seriesUid2 = DicomUid.GenerateUid().UID;
			string seriesUid3 = DicomUid.GenerateUid().UID;
			string seriesUid4 = DicomUid.GenerateUid().UID;
			string seriesUid5 = DicomUid.GenerateUid().UID;

			string imageUid1 = DicomUid.GenerateUid().UID;
			string imageUid2 = DicomUid.GenerateUid().UID;
			string imageUid3 = DicomUid.GenerateUid().UID;
			string imageUid4 = DicomUid.GenerateUid().UID;
			string imageUid5 = DicomUid.GenerateUid().UID;
			string imageUid6 = DicomUid.GenerateUid().UID;
			string imageUid7 = DicomUid.GenerateUid().UID;
			string imageUid8 = DicomUid.GenerateUid().UID;
			string imageUid9 = DicomUid.GenerateUid().UID;

			ImageSop image1 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);
			ImageSop image2 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid2);
			ImageSop image3 = CreateImageSop("patient1", studyUid1, seriesUid2, imageUid3);
			ImageSop image4 = CreateImageSop("patient1", studyUid1, seriesUid2, imageUid4);
			ImageSop image5 = CreateImageSop("patient1", studyUid2, seriesUid3, imageUid5);
			ImageSop image6 = CreateImageSop("patient1", studyUid2, seriesUid3, imageUid6);
			ImageSop image7 = CreateImageSop("patient2", studyUid3, seriesUid4, imageUid7);
			ImageSop image8 = CreateImageSop("patient2", studyUid3, seriesUid4, imageUid8);
			ImageSop image9 = CreateImageSop("patient2", studyUid3, seriesUid5, imageUid9);

			// This is an internal method.  We would never do this from real
			// client code, but we do it here because we just want to test that
			// images are being properly added to the tree. 
			studyTree.AddSop(image1);
			studyTree.AddSop(image2);
			studyTree.AddSop(image3);
			studyTree.AddSop(image4);
			studyTree.AddSop(image5);
			studyTree.AddSop(image6);
			studyTree.AddSop(image7);
			studyTree.AddSop(image8);
			studyTree.AddSop(image9);

			Assert.IsTrue(studyTree.Patients.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies.Count == 1);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid2].Series.Count == 1);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid2].Series.Count == 1);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies[studyUid3].Series.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid1].Sops.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid2].Sops.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid2].Series[seriesUid3].Sops.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies[studyUid3].Series[seriesUid4].Sops.Count == 2);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies[studyUid3].Series[seriesUid5].Sops.Count == 1);

			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid1].Sops[imageUid1].SopInstanceUid == image1.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid1].Sops[imageUid2].SopInstanceUid == image2.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid2].Sops[imageUid3].SopInstanceUid == image3.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid2].Sops[imageUid4].SopInstanceUid == image4.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid2].Series[seriesUid3].Sops[imageUid5].SopInstanceUid == image5.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid2].Series[seriesUid3].Sops[imageUid6].SopInstanceUid == image6.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies[studyUid3].Series[seriesUid4].Sops[imageUid7].SopInstanceUid == image7.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies[studyUid3].Series[seriesUid4].Sops[imageUid8].SopInstanceUid == image8.SopInstanceUid);
			Assert.IsTrue(studyTree.Patients["patient2"].Studies[studyUid3].Series[seriesUid5].Sops[imageUid9].SopInstanceUid == image9.SopInstanceUid);

			Assert.IsTrue(studyTree.GetSop(imageUid1).SopInstanceUid == image1.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid2).SopInstanceUid == image2.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid3).SopInstanceUid == image3.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid4).SopInstanceUid == image4.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid5).SopInstanceUid == image5.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid6).SopInstanceUid == image6.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid7).SopInstanceUid == image7.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid8).SopInstanceUid == image8.SopInstanceUid);
			Assert.IsTrue(studyTree.GetSop(imageUid9).SopInstanceUid == image9.SopInstanceUid);

			viewer.Dispose();
		}
Ejemplo n.º 48
0
	    protected override void OnStop()
		{
			if (_viewerHandler != null)
			{
				_viewerHandler.Dispose();
				_viewerHandler = null;
			}

			//TODO (CR May 2010): WebDesktopWindow shouldn't hang around, but we can check.
			if (_viewer != null)
			{
				_viewer.Stop();
				_viewer.Dispose();
				_viewer = null;
			}
		}
Ejemplo n.º 49
0
		public void AddDuplicateImage()
		{
			IImageViewer viewer = new ImageViewerComponent();
			StudyTree studyTree = viewer.StudyTree;

			string studyUid1 = DicomUid.GenerateUid().UID;
			string seriesUid1 = DicomUid.GenerateUid().UID;
			string imageUid1 = DicomUid.GenerateUid().UID;

			ImageSop image1 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);
			ImageSop image2 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);

			//The sop has already silently disposed the 2nd data source.
			Assert.IsTrue(ReferenceEquals(image1.DataSource, image2.DataSource));
			studyTree.AddSop(image1);
			studyTree.AddSop(image2);

			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid1].Sops.Count == 1);

			TestDataSource dataSource = (TestDataSource) image1.DataSource;
			viewer.Dispose();

			Assert.IsTrue(dataSource.IsDisposed);
		}
Ejemplo n.º 50
0
		public void AddDuplicateImage()
		{
			IImageViewer viewer = new ImageViewerComponent();
			StudyTree studyTree = viewer.StudyTree;

			string studyUid1 = DicomUid.GenerateUid().UID;
			string seriesUid1 = DicomUid.GenerateUid().UID;
			string imageUid1 = DicomUid.GenerateUid().UID;

			ImageSop image1 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);
			ImageSop image2 = CreateImageSop("patient1", studyUid1, seriesUid1, imageUid1);

			Assert.IsTrue(studyTree.AddSop(image1));
			Assert.IsFalse(studyTree.AddSop(image2));

			Assert.IsTrue(studyTree.Patients["patient1"].Studies[studyUid1].Series[seriesUid1].Sops.Count == 1);

			TestDataSource dataSource = (TestDataSource) image1.DataSource;
			viewer.Dispose();

			Assert.IsTrue(dataSource.IsDisposed);
		}
        private void NewToolSet()
        {
            _viewer = new ImageViewerComponent();
            _context = new TestToolContext(_viewer);
            _toolSet = new ToolSet(CreateTools(), _context);

            MouseToolSettingsProfile.Reset();
        }
Ejemplo n.º 52
0
			public SingleStudyLoader(SynchronizationContext uiThreadContext, ImageViewerComponent viewer, LoadStudyArgs args)
				: this(uiThreadContext, viewer)
			{
				_args = args;
			}
Ejemplo n.º 53
0
 public void SetComponent(IApplicationComponent component)
 {
     _component = (ImageViewerComponent)component;
 }
Ejemplo n.º 54
0
			public AsynchronousPriorStudyLoader(ImageViewerComponent imageViewer, IPriorStudyFinder priorStudyFinder)
			{
				_imageViewer = imageViewer;
				_singleStudyLoaders = new List<SingleStudyLoader>();
				_priorStudyFinder = priorStudyFinder ?? PriorStudyFinder.Null;
				_priorStudyFinder.SetImageViewer(_imageViewer);
			}