Example #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;
            }
        }
Example #2
0
        public void Shutdown()
        {
            if (!_shuttingDown)
            {
                _shuttingDown = true;
                EventMediator.StopApplication();

                Visibility = Visibility.Collapsed;

                if (_studyView != null)
                {
                    StudyViewContainer.Children.Clear();

                    MouseHelper.SetBackgroundElement(null);
                    _studyView.Dispose();
                    _studyView = null;
                }
            }
        }
Example #3
0
        public virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                Shutdown();

                // Must do this beofre we work with the EventMediator
                ToolstripViewComponent.Dispose();

                if (_studyView != null)
                {
                    StudyViewContainer.Children.Clear();
                    if (disposing)
                    {
                        _studyView.Dispose();
                    }
                    _studyView = null;
                }

                if (EventMediator != null)
                {
                    if (_serverApplication != null)
                    {
                        EventMediator.UnregisterEventHandler(typeof(ApplicationStartedEvent), ApplicationStarted);
                        EventMediator.UnregisterEventHandler(_serverApplication.Viewer.Identifier);
                        EventMediator.ServerApplicationStopped -= OnServerApplicationStopped;
                        _serverApplication = null;
                    }

                    EventMediator.Dispose();
                    EventMediator = null;
                }


                _disposed = true;
            }
        }