Esempio n. 1
0
        public ImageViewer(StartViewerApplicationRequest startRequest)
        {
            InitializeComponent();
            ViewModel = new ImageViewerViewModel
            {
                IsLoading = true
            };

            DataContext = ViewModel;

            if (ApplicationContext.Current != null)
            {
                ApplicationContext.Initialize();
                if (ApplicationContext.Current == null)
                {
                    throw new Exception();
                }
            }

            EventMediator = new ServerEventMediator();
            EventMediator.Initialize(ApplicationContext.Current.Parameters);

            EventMediator.CriticalError += ErrorHandler_OnCriticalError;

            EventMediator.RegisterEventHandler(typeof(ApplicationStartedEvent), ApplicationStarted);
            EventMediator.RegisterEventHandler(typeof(SessionUpdatedEvent), OnSessionUpdated);
            EventMediator.RegisterEventHandler(typeof(MessageBoxShownEvent), OnMessageBox);
            EventMediator.ServerApplicationStopped += OnServerApplicationStopped;

            _studyView = new StudyView(EventMediator);
            StudyViewContainer.Children.Add(_studyView);
            MouseHelper.SetBackgroundElement(LayoutRoot);

            if (startRequest == null)
            {
                //TODO: replace this with the custom dialog. For some reason, it doesn't work here.
                System.Windows.MessageBox.Show(ErrorMessages.MissingParameters);
            }
            else
            {
                ToolstripViewComponent.EventDispatcher = EventMediator;

                LayoutRoot.MouseLeftButtonDown  += ToolstripViewComponent.OnLoseFocus;
                LayoutRoot.MouseRightButtonDown += ToolstripViewComponent.OnLoseFocus;

                EventMediator.StartApplication(startRequest);

                TileView.ApplicationRootVisual = _studyView.StudyViewCanvas;

                LayoutRoot.KeyUp += OnKeyUp;
            }
        }
Esempio n. 2
0
        public ImageViewer(StartViewerApplicationRequest startRequest)
        {
            InitializeComponent();
            ViewModel = new ImageViewerViewModel
                            {
                                IsLoading = true
                            };
            
            DataContext = ViewModel;

            if (ApplicationContext.Current != null)
            {
                ApplicationContext.Initialize();
                if (ApplicationContext.Current == null) throw new Exception();
            }

            EventMediator = new ServerEventMediator();
            EventMediator.Initialize(ApplicationContext.Current.Parameters);

            EventMediator.CriticalError += ErrorHandler_OnCriticalError;

			EventMediator.RegisterEventHandler(typeof(ApplicationStartedEvent), ApplicationStarted);
            EventMediator.RegisterEventHandler(typeof(SessionUpdatedEvent), OnSessionUpdated);
            EventMediator.RegisterEventHandler(typeof(MessageBoxShownEvent), OnMessageBox);
            EventMediator.ServerApplicationStopped += OnServerApplicationStopped;
            
            _studyView = new StudyView(EventMediator);
			StudyViewContainer.Children.Add(_studyView);
            MouseHelper.SetBackgroundElement(LayoutRoot);

            if (startRequest == null)
            {
                //TODO: replace this with the custom dialog. For some reason, it doesn't work here.
                System.Windows.MessageBox.Show(ErrorMessages.MissingParameters);
            }
            else
            {

                ToolstripViewComponent.EventDispatcher = EventMediator;

                LayoutRoot.MouseLeftButtonDown += ToolstripViewComponent.OnLoseFocus;
                LayoutRoot.MouseRightButtonDown += ToolstripViewComponent.OnLoseFocus;

                EventMediator.StartApplication(startRequest);

                TileView.ApplicationRootVisual = _studyView.StudyViewCanvas;
                
                LayoutRoot.KeyUp += OnKeyUp;
            }
		}
Esempio n. 3
0
        private ImageViewerComponent CreateViewerComponent(StartViewerApplicationRequest request)
        {
            var keyImagesOnly = request.LoadStudyOptions != null && request.LoadStudyOptions.KeyImagesOnly;
            var excludePriors = request.LoadStudyOptions != null && request.LoadStudyOptions.ExcludePriors;

            if (keyImagesOnly)
            {
                var layoutManager = new ImageViewer.Layout.Basic.LayoutManager()
                {
                    LayoutHook = new KeyImageLayoutHook()
                };
                //override the KO options
                const string ko          = "KO";
                var          realOptions = new KeyImageDisplaySetCreationOptions(layoutManager.DisplaySetCreationOptions[ko]);
                layoutManager.DisplaySetCreationOptions[ko] = realOptions;


                if (excludePriors)
                {
                    return(new ImageViewerComponent(layoutManager, PriorStudyFinder.Null));
                }
                else
                {
                    return(new ImageViewerComponent(layoutManager));
                }
            }
            else
            {
                ImageViewer.Layout.Basic.LayoutManager layoutManager;

                layoutManager = new ImageViewer.Layout.Basic.LayoutManager()
                {
                    LayoutHook = (request.LoadStudyOptions != null && request.LoadStudyOptions.PreferredLayout != null)
                                ? new CustomLayoutHook(request.LoadStudyOptions.PreferredLayout.Rows, request.LoadStudyOptions.PreferredLayout.Columns)
                                : new CustomLayoutHook()
                };

                if (excludePriors)
                {
                    return(new ImageViewerComponent(layoutManager, PriorStudyFinder.Null));
                }
                else
                {
                    return(new ImageViewerComponent(layoutManager));
                }
            }
        }
Esempio n. 4
0
        private void StartWebViewer()
        {
            var rootPanel = RootVisual as Panel;
            
            //TODO (CR May 2010): need the lock?
            lock (_startLock)
            {
                if (_context != null)
                    return;

                _context = ApplicationContext.Initialize();
            }

            string query = HtmlPage.Document.DocumentUri.Query;

            Imageviewer viewer;

            if (!string.IsNullOrEmpty(query))
            {
                var request = new StartViewerApplicationRequest
                {
                    AccessionNumber = new ObservableCollection<string>(),
                    StudyInstanceUid = new ObservableCollection<string>(),
                    PatientId = new ObservableCollection<string>()
                };

                string[] vals = HttpUtility.UrlDecode(query).Split(new[] { '?', ';', '=', ',', '&' });
                for (int i = 0; i < vals.Length - 1; i++)
                {
                    if (String.IsNullOrEmpty(vals[i]))
                        continue;

                    if (vals[i].Equals("study"))
                    {
                        i++;
                        request.StudyInstanceUid.Add(vals[i]);
                    }
                    else if (vals[i].Equals("patientid"))
                    {
                        i++;
                        request.PatientId.Add(vals[i]);
                    }
                    else if (vals[i].Equals("aetitle"))
                    {
                        i++;
                        request.AeTitle = vals[i];
                    }
                    else if (vals[i].Equals("accession"))
                    {
                        i++;
                        request.AccessionNumber.Add(vals[i]);
                    }
                    else if (vals[i].Equals("application"))
                    {
                        i++;
                        request.ApplicationName = vals[i];
                    }
                }

                request.Username = ApplicationContext.Current.Parameters.Username;
                request.SessionId = ApplicationContext.Current.Parameters.SessionToken;
                request.IsSessionShared = ApplicationContext.Current.Parameters.IsSessionShared;

                viewer = new Imageviewer(request);
            }
            else
            {
                viewer = new Imageviewer(null);
            }

            viewer.EventMediator.CriticalError += CriticalError;
            viewer.EventMediator.ServerApplicationStopped += OnServerApplicationStopped;
            viewer.EventMediator.ChannelOpened += OnChannelOpened;
            viewer.EventMediator.ChannelOpening += OnChannelOpening;
            viewer.EventMediator.WarningEvent += OnWarning;

            if (rootPanel != null)
            {
                // Add a Log Panel at the bottom of the screen.  This can be opened by CTRL-ALT-L.
                _logPanel = new LogPanel
                {
                    Visibility = Visibility.Collapsed,
                    Height = 200
                };
                var theGrid = new Grid();
                theGrid.RowDefinitions.Add(new RowDefinition());
                theGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0, GridUnitType.Auto) });
                _logPanel.SetValue(Grid.RowProperty, 1);
                viewer.SetValue(Grid.RowProperty, 0);
                theGrid.Children.Add(viewer);
                theGrid.Children.Add(_logPanel);
                rootPanel.Children.Add(theGrid);
                rootPanel.KeyUp += OnKeyUp;
                rootPanel.UpdateLayout();
            }
        }
Esempio n. 5
0
        private static IList <StudyRootStudyIdentifier> FindStudies(StartViewerApplicationRequest request)
        {
            bool invalidRequest = true;
            List <StudyRootStudyIdentifier> results = new List <StudyRootStudyIdentifier>();

            using (StudyRootQueryBridge bridge = new StudyRootQueryBridge(Platform.GetService <IStudyRootQuery>()))
            {
                if (request.StudyInstanceUid != null && request.StudyInstanceUid.Length > 0)
                {
                    foreach (string studyUid in request.StudyInstanceUid)
                    {
                        //TODO (CR May 2010): can actually trigger a query of all studies
                        if (!String.IsNullOrEmpty(studyUid))
                        {
                            invalidRequest = false;
                        }

                        //TODO (CR May 2010): if request.AeTitle is set, assign RetrieveAeTitle parameter in
                        // StudyRootStudyIndentifer to this value.  Update the query code to then only
                        // search this specified partition and remove the loop code below that looks
                        // for matching AeTitles.
                        StudyRootStudyIdentifier identifier = new StudyRootStudyIdentifier
                        {
                            StudyInstanceUid = studyUid
                        };
                        IList <StudyRootStudyIdentifier> studies = bridge.StudyQuery(identifier);

                        bool found = false;
                        foreach (StudyRootStudyIdentifier study in studies)
                        {
                            if (!string.IsNullOrEmpty(request.AeTitle) && !study.RetrieveAeTitle.Equals(request.AeTitle))
                            {
                                continue;
                            }

                            results.Add(study);
                            found = true;
                        }

                        if (!found)
                        {
                            throw new NotFoundLoadStudyException(studyUid);
                        }
                    }
                }
                if (request.PatientId != null && request.PatientId.Length > 0)
                {
                    foreach (string patientId in request.PatientId)
                    {
                        if (!String.IsNullOrEmpty(patientId))
                        {
                            invalidRequest = false;
                        }

                        StudyRootStudyIdentifier identifier = new StudyRootStudyIdentifier
                        {
                            PatientId = patientId
                        };

                        IList <StudyRootStudyIdentifier> studies = bridge.StudyQuery(identifier);
                        bool found = false;
                        foreach (StudyRootStudyIdentifier study in studies)
                        {
                            if (!string.IsNullOrEmpty(request.AeTitle) && !study.RetrieveAeTitle.Equals(request.AeTitle))
                            {
                                continue;
                            }

                            results.Add(study);
                            found = true;
                        }

                        if (!found)
                        {
                            throw new PatientStudiesNotFoundException(patientId);
                        }
                    }
                }
                if (request.AccessionNumber != null && request.AccessionNumber.Length > 0)
                {
                    foreach (string accession in request.AccessionNumber)
                    {
                        if (!String.IsNullOrEmpty(accession))
                        {
                            invalidRequest = false;
                        }

                        StudyRootStudyIdentifier identifier = new StudyRootStudyIdentifier
                        {
                            AccessionNumber = accession
                        };

                        IList <StudyRootStudyIdentifier> studies = bridge.StudyQuery(identifier);

                        bool found = false;
                        foreach (StudyRootStudyIdentifier study in studies)
                        {
                            if (!string.IsNullOrEmpty(request.AeTitle) && !study.RetrieveAeTitle.Equals(request.AeTitle))
                            {
                                continue;
                            }

                            results.Add(study);
                            found = true;
                        }

                        if (!found)
                        {
                            throw new AccessionStudiesNotFoundException(accession);
                        }
                    }
                }
            }

            if (invalidRequest)
            {
                throw new InvalidRequestException();
            }

            return(results);
        }
Esempio n. 6
0
        private void StartWebViewer()
        {
            var rootPanel = RootVisual as Panel;

            //TODO (CR May 2010): need the lock?
            lock (_startLock)
            {
                if (_context != null)
                {
                    return;
                }

                _context = ApplicationContext.Initialize();
            }

            string query = HtmlPage.Document.DocumentUri.Query;

            Imageviewer viewer;

            if (!string.IsNullOrEmpty(query))
            {
                var request = new StartViewerApplicationRequest
                {
                    AccessionNumber  = new ObservableCollection <string>(),
                    StudyInstanceUid = new ObservableCollection <string>(),
                    PatientId        = new ObservableCollection <string>()
                };

                string[] vals = HttpUtility.UrlDecode(query).Split(new[] { '?', ';', '=', ',', '&' });
                for (int i = 0; i < vals.Length - 1; i++)
                {
                    if (String.IsNullOrEmpty(vals[i]))
                    {
                        continue;
                    }

                    if (vals[i].Equals("study"))
                    {
                        i++;
                        request.StudyInstanceUid.Add(vals[i]);
                    }
                    else if (vals[i].Equals("patientid"))
                    {
                        i++;
                        request.PatientId.Add(vals[i]);
                    }
                    else if (vals[i].Equals("aetitle"))
                    {
                        i++;
                        request.AeTitle = vals[i];
                    }
                    else if (vals[i].Equals("accession"))
                    {
                        i++;
                        request.AccessionNumber.Add(vals[i]);
                    }
                    else if (vals[i].Equals("application"))
                    {
                        i++;
                        request.ApplicationName = vals[i];
                    }
                }

                request.Username        = ApplicationContext.Current.Parameters.Username;
                request.SessionId       = ApplicationContext.Current.Parameters.SessionToken;
                request.IsSessionShared = ApplicationContext.Current.Parameters.IsSessionShared;

                viewer = new Imageviewer(request);
            }
            else
            {
                viewer = new Imageviewer(null);
            }

            viewer.EventMediator.CriticalError            += CriticalError;
            viewer.EventMediator.ServerApplicationStopped += OnServerApplicationStopped;
            viewer.EventMediator.ChannelOpened            += OnChannelOpened;
            viewer.EventMediator.ChannelOpening           += OnChannelOpening;
            viewer.EventMediator.WarningEvent             += OnWarning;

            if (rootPanel != null)
            {
                // Add a Log Panel at the bottom of the screen.  This can be opened by CTRL-ALT-L.
                _logPanel = new LogPanel
                {
                    Visibility = Visibility.Collapsed,
                    Height     = 200
                };
                var theGrid = new Grid();
                theGrid.RowDefinitions.Add(new RowDefinition());
                theGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(0, GridUnitType.Auto)
                });
                _logPanel.SetValue(Grid.RowProperty, 1);
                viewer.SetValue(Grid.RowProperty, 0);
                theGrid.Children.Add(viewer);
                theGrid.Children.Add(_logPanel);
                rootPanel.Children.Add(theGrid);
                rootPanel.KeyUp += OnKeyUp;
                rootPanel.UpdateLayout();
            }
        }