Exemplo n.º 1
0
        /// <summary>
        /// Displays a message box.
        /// </summary>
        /// <remarks>
        /// Override this method if you need to customize the display of message boxes.
        /// </remarks>
        /// <param name="message"></param>
        /// <param name="buttons"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public virtual DialogBoxAction ShowMessageBox(string message, string title, MessageBoxActions buttons)
        {
            if (ApplicationContext.Current != null)
            {
                MessageBoxEntityHandler handler = EntityHandler.Create <MessageBoxEntityHandler>();
                handler.SetModelObject(this);

                MessageBox box = handler.GetEntity();
                box.Message = message;
                box.Title   = title;
                switch (buttons)
                {
                case MessageBoxActions.Ok:
                    box.Actions = WebMessageBoxActions.Ok;
                    _result     = DialogBoxAction.Ok;
                    break;

                case MessageBoxActions.OkCancel:
                    box.Actions = WebMessageBoxActions.OkCancel;
                    _result     = DialogBoxAction.Ok;
                    break;

                case MessageBoxActions.YesNo:
                    box.Actions = WebMessageBoxActions.YesNo;
                    _result     = DialogBoxAction.Yes;
                    break;

                case MessageBoxActions.YesNoCancel:
                    box.Actions = WebMessageBoxActions.YesNoCancel;
                    _result     = DialogBoxAction.Yes;
                    break;
                }

                MessageBoxShownEvent @event = new MessageBoxShownEvent
                {
                    Identifier = box.Identifier,
                    MessageBox = box,
                    SenderId   = ApplicationContext.Current.ApplicationId,
                };

                ApplicationContext.Current.FireEvent(@event);

                IWebSynchronizationContext context = (SynchronizationContext.Current as IWebSynchronizationContext);
                if (context != null)
                {
                    context.RunModal();
                }
                return(_result);
            }

            return(DialogBoxAction.Ok);
        }
Exemplo n.º 2
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);
        }