public ImageBoxScrollbarView(ImageBox imageBox, ServerEventMediator eventMediator)
        {
            _eventMediator = eventMediator;
            IsTabStop = true; // allow focus
            ServerEntity = imageBox;

            DataContext = imageBox; 
            
            InitializeComponent();

            LayoutRoot.IsHitTestVisible = !imageBox.Tiles.Any(t => t.HasCapture);

            _eventMediator.TileHasCaptureChanged += EventBrokerTileHasCaptureChanged;

            ImageScrollBar.SetBinding(RangeBase.ValueProperty,
                    new Binding(TopLeftPresentationImageIndexPropertyName) { 
                        Mode = BindingMode.OneTime 
            });

            ImageScrollBar.Maximum = ServerEntity.ImageCount - ServerEntity.Tiles.Count;
            ImageScrollBar.Visibility = ImageScrollBar.Maximum > 0 ? Visibility.Visible : Visibility.Collapsed;

            ServerEntity.PropertyChanged += OnPropertyChanged;

            _scrollbarEventPublisher =
                new DelayedEventPublisher<ScrollBarUpdateEventArgs>(
                    (s, ev) => _eventMediator.DispatchMessage(new UpdatePropertyMessage
                                                                  {
                                                                      Identifier = Guid.NewGuid(),
                                                                      PropertyName =
                                                                          TopLeftPresentationImageIndexPropertyName,
                                                                      TargetId = ServerEntity.Identifier,
                                                                      Value = ev.ScrollbarPosition
                                                                  }), 100);
        }
        public void Destroy()
        {
            _destroyed = true;
            if (_eventMediator != null)
            {
                _eventMediator.UnregisterEventHandler(ServerEntity.Identifier);

                _eventMediator.TileHasCaptureChanged -= EventBrokerTileHasCaptureChanged;
                _eventMediator = null;
            }

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

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

            StopMouseMoveTimer();
        }
        public TileView(Tile serverEntity, ServerEventMediator mediator)
        {
            IsTabStop = true; // allow focus

            ServerEntity = serverEntity;

            if (ServerEntity.Selected)
            {
                MouseHelper.SetActiveElement(this);
            }
            _eventMediator = mediator;

            _eventMediator.RegisterEventHandler(ServerEntity.Identifier, OnTileEvent);

            InitializeComponent();

            //TODO (CR May 2010): would mediator design pattern simplify this by giving the mousehelper more control?
            TileImage.MouseRightButtonDown += OnDirectMouseRightButtonDown;
            TileImage.MouseLeftButtonDown  += OnDirectMouseLeftButtonDown;

            TileCanvas.MouseLeave += OnMouseLeave;
            TileCanvas.MouseEnter += OnMouseEnter;

            _eventMediator.TileHasCaptureChanged += EventBrokerTileHasCaptureChanged;
        }
Exemple #4
0
        public ImageBoxView(ImageBox serverEntity, ServerEventMediator eventMediator)
        {
			ServerEntity = serverEntity;
            _eventMediator = eventMediator;
			_eventMediator.RegisterEventHandler(serverEntity.Identifier, OnImageBoxEvent);
            InitializeComponent();
			UpdateTileViews();
        }
Exemple #5
0
 public ImageBoxView(ImageBox serverEntity, ServerEventMediator eventMediator)
 {
     ServerEntity   = serverEntity;
     _eventMediator = eventMediator;
     _eventMediator.RegisterEventHandler(serverEntity.Identifier, OnImageBoxEvent);
     InitializeComponent();
     UpdateTileViews();
 }
Exemple #6
0
        public StudyView(ServerEventMediator eventMediator)
        {
            InitializeComponent();
            _eventMediator = eventMediator;
            _imageBoxViews = new List<ImageBoxView>();

			SizeChanged += OnSizeChanged;
            _resizePublisher = new DelayedEventPublisher<EventArgs>(ResizeEvent, 350);
        }
Exemple #7
0
        public StudyView(ServerEventMediator eventMediator)
        {
            InitializeComponent();
            _eventMediator = eventMediator;
            _imageBoxViews = new List<ImageBoxView>();

			SizeChanged += OnSizeChanged;
            _resizePublisher = new DelayedEventPublisher<EventArgs>(ResizeEvent, 350);
        }
Exemple #8
0
        public void Destroy()
        {
            if (_eventMediator != null)
            {
                _eventMediator.UnregisterEventHandler(ServerEntity.Identifier);
                _eventMediator = null;
            }

            DestroyTileViews();

            ServerEntity = null;
        }
Exemple #9
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;
            }
        }
Exemple #10
0
	    public void Dispose()
	    {
            if (_eventDispatcher != null)
            {
                foreach (Guid g in _map.Keys)
                {
                    _eventDispatcher.UnregisterEventHandler(g);
                }

                _eventDispatcher = null;
                _map.Clear();
            }
	    }
Exemple #11
0
        public void Dispose()
        {
            if (_eventDispatcher != null)
            {
                foreach (Guid g in _map.Keys)
                {
                    _eventDispatcher.UnregisterEventHandler(g);
                }

                _eventDispatcher = null;
                _map.Clear();
            }
        }
Exemple #12
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;
            }
		}
Exemple #13
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;
            }
        }
Exemple #14
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                System.Windows.Application.Current.Host.Content.Resized -= OnApplicationResized;

                if (disposing)
                {
                    foreach (var c in LayoutRoot.Children)
                    {
                        var d = c as IDisposable;
                        if (d != null)
                        {
                            d.Dispose();
                        }
                    }
                }

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

                if (_eventMediator != null)
                {
                    _eventMediator.TileHasCaptureChanged -= EventBrokerTileHasCapture;
                    _eventMediator = null;
                }


                LayoutRoot.Children.Clear();

                _disposed = true;
            }
        }
        public ImageBoxScrollbarView(ImageBox imageBox, ServerEventMediator eventMediator)
        {
            _eventMediator = eventMediator;
            IsTabStop      = true; // allow focus
            ServerEntity   = imageBox;

            DataContext = imageBox;

            InitializeComponent();

            LayoutRoot.IsHitTestVisible = !imageBox.Tiles.Any(t => t.HasCapture);

            _eventMediator.TileHasCaptureChanged += EventBrokerTileHasCaptureChanged;

            ImageScrollBar.SetBinding(RangeBase.ValueProperty,
                                      new Binding(TopLeftPresentationImageIndexPropertyName)
            {
                Mode = BindingMode.OneTime
            });

            ImageScrollBar.Maximum    = ServerEntity.ImageCount - ServerEntity.Tiles.Count;
            ImageScrollBar.Visibility = ImageScrollBar.Maximum > 0 ? Visibility.Visible : Visibility.Collapsed;

            ServerEntity.PropertyChanged += OnPropertyChanged;

            _scrollbarEventPublisher =
                new DelayedEventPublisher <ScrollBarUpdateEventArgs>(
                    (s, ev) => _eventMediator.DispatchMessage(new UpdatePropertyMessage
            {
                Identifier   = Guid.NewGuid(),
                PropertyName =
                    TopLeftPresentationImageIndexPropertyName,
                TargetId = ServerEntity.Identifier,
                Value    = ev.ScrollbarPosition
            }), 100);
        }
Exemple #16
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;
            }
        }
Exemple #17
0
		public ActionDispatcher(ServerEventMediator dispatcher)
		{
		    _eventDispatcher = dispatcher;

		}
Exemple #18
0
		public void Destroy()
        {
            if (_eventMediator != null)
            {
                _eventMediator.UnregisterEventHandler(ServerEntity.Identifier);
                _eventMediator = null;
            }

		    DestroyTileViews();

		    ServerEntity = null;
        }
Exemple #19
0
 public ActionDispatcher(ServerEventMediator dispatcher)
 {
     _eventDispatcher = dispatcher;
 }
Exemple #20
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                System.Windows.Application.Current.Host.Content.Resized -= OnApplicationResized;

                if (disposing)
                {
                    foreach (var c in LayoutRoot.Children)
                    {
                        var d = c as IDisposable;
                        if (d!= null)
                            d.Dispose();
                    }
                } 
                
                if (_dispatcher != null)
                {
                    _dispatcher.Dispose();
                    _dispatcher = null;
                }

                if (_eventMediator != null)
                {
                    _eventMediator.TileHasCaptureChanged -= EventBrokerTileHasCapture;
                    _eventMediator = null;
                }
             

                LayoutRoot.Children.Clear();

                _disposed = true;
            }
        }
Exemple #21
0
 internal static IPopup BuildContextMenu(WebActionNode model, ServerEventMediator dispatcher)
 {
     return(BuildContextMenu(model, new ActionDispatcher(dispatcher)));
 }
Exemple #22
0
 internal static IPopup BuildContextMenu(WebActionNode model, ServerEventMediator dispatcher)
 {
     return BuildContextMenu(model, new ActionDispatcher(dispatcher));
 }