コード例 #1
0
 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;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        /// <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");
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        private void OnWorkspaceChanged(object sender, ItemEventArgs <Workspace> e)
        {
            IImageViewer viewer = null;

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

            SetActiveViewer(viewer);
        }
コード例 #6
0
        private static IImageViewer CastToImageViewer(Workspace workspace)
        {
            IImageViewer viewer = null;

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

            return(viewer);
        }
コード例 #7
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());
        }
コード例 #8
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);
        }
コード例 #9
0
        private static Workspace GetViewerWorkspace(IImageViewer viewer)
        {
            foreach (Workspace workspace in GetViewerWorkspaces())
            {
                IImageViewer workspaceViewer = ImageViewerComponent.GetAsImageViewer(workspace);
                if (viewer == workspaceViewer)
                {
                    return(workspace);
                }
            }

            return(null);
        }
コード例 #10
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);
             }
         }
     }
 }
コード例 #11
0
        /// <summary>
        /// Helper method to update the component from the active workspace.
        /// </summary>
        /// <param name="workspace"></param>
        private void UpdatePatientInfo(Workspace workspace)
        {
            IImageViewer viewer = ImageViewerComponent.GetAsImageViewer(workspace);

            if (viewer != null)
            {
                Patient patient = CollectionUtils.FirstElement <Patient>(viewer.StudyTree.Patients);
                this.PatientInfo = string.Format("{0} {1}", patient.PatientId, patient.PatientsName);

                _appointments.Items.Clear();
                _appointments.Items.AddRange(_calendar.GetEvents(_patientInfo, null, null));
            }
            else
            {
                this.PatientInfo = null;
            }
        }
コード例 #12
0
        public OpenViewerOutput OpenViewer(OpenViewerInput input)
        {
            Platform.CheckForNullReference(input, "input");
            Platform.CheckMemberIsSet(input.StudyInstanceUids, "StudyInstanceUids");

            if (input.StudyInstanceUids.Length == 0)
            {
                return(new OpenViewerOutput());
            }

            var helper = new OpenStudyHelper();

            foreach (var studyInstanceUid in input.StudyInstanceUids)
            {
                helper.AddStudy(studyInstanceUid, null, "DICOM_LOCAL");
            }

            var id = Interlocked.Increment(ref _viewerId);

            helper.Title = "imageviewer " + id;

            var viewer = helper.OpenStudies();

            var workspace = Application.ActiveDesktopWindow.Workspaces
                            .First(w => ImageViewerComponent.GetAsImageViewer(w) == viewer);

            lock (_viewers)
            {
                _viewers.Add(id, viewer);
            }

            workspace.Closed += (sender, e) =>
            {
                lock (_viewers)
                {
                    _viewers.Remove(id);
                }
            };

            return(new OpenViewerOutput {
                ViewerId = id
            });
        }
コード例 #13
0
        private void OnWorkspaceActivationChanged(object sender, ItemEventArgs <Workspace> e)
        {
            if (!e.Item.Active)
            {
                return;
            }

            IImageViewer viewer = ImageViewerComponent.GetAsImageViewer(e.Item);

            if (viewer == base.ImageViewer)
            {
                //make the list of tools reflect the activation order, most recent first
                lock (_syncLock)
                {
                    _tools.Remove(this);
                    _tools.Insert(0, this);
                }
            }
        }
コード例 #14
0
        internal static KeyImageInformation GetKeyImageInformation(Workspace workspace)
        {
            IImageViewer viewer = ImageViewerComponent.GetAsImageViewer(workspace);

            return(GetKeyImageInformation(viewer));
        }
コード例 #15
0
        internal static KeyImageClipboard GetKeyImageClipboard(Workspace workspace)
        {
            IImageViewer viewer = ImageViewerComponent.GetAsImageViewer(workspace);

            return(GetKeyImageClipboard(viewer));
        }