public void OnHelpRequested(EventArgs e)
        {
            if (_shellModuleService.ActiveModule == _module)
            {
                EventHandler <HelpRequestedEventArgs> temp = HelpRequested;

                ShellConfigurationSection config = ConfigurationManager.GetSection(ShellConfigurationSection.SectionKey) as ShellConfigurationSection;

                HelpRequestedEventArgs args = new HelpRequestedEventArgs();
                args.HelpBaseUri = config.HelpBaseUri;

                if (temp != null)
                {
                    temp(this, args);
                }
                else
                {
                    args.Cancel = true;
                }

                if (args.Cancel)
                {
                    IMessageBoxView messageBoxView = _workItem.SmartParts.AddNew <MessageBoxView>();
                    messageBoxView.Show(_shellView.Model.Module.Title, StringResources.No_Help_Message, null, Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Information);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Checks if the designer document has changed and asks the user to confirm the change. Will save current layout if requested. Document is marked clean if the change is not cancelled.
        /// </summary>
        /// <param name="e">The event args that allow for cancellation.</param>
        /// <returns>Value indicating whether the change is confirmed or not.</returns>
        private bool CheckForChangesAndConfirmDisposition(CancelEventArgs e)
        {
            bool confirmed = true;

            if (this.currentLayout != null && this.IsDocumentDirty())
            {
                IMessageBoxView  messageBox = this.container.Resolve <IMessageBoxView>();
                MessageBoxResult result     = messageBox.Show(string.Format(CultureInfo.InvariantCulture, PresenterResources.SaveLayoutChanges, this.SaveLayoutName()), PresenterResources.MicrosoftWord, MessageBoxViewButtons.YesNoCancel, MessageBoxViewIcon.Warning);
                if (result == MessageBoxResult.Yes)
                {
                    this.SaveChanges();
                }
                else if (result == MessageBoxResult.No)
                {
                    if (this.RenameIsPending())
                    {
                        this.SetViewLayoutList();
                    }

                    this.SetDocumentClean();
                }

                confirmed = result == MessageBoxResult.Yes || result == MessageBoxResult.No;

                e.Cancel = !confirmed;
            }

            return(confirmed);
        }
        public MessageBoxResult ShowNotAuhtorizedMessageBox()
        {
            IMessageBoxView messageBoxView = _workItem.SmartParts.AddNew <MessageBoxView>();

            return(messageBoxView.Show(StringResources.Authorization_NotAuhtorized
                                       , StringResources.Authorization_Message
                                       , null
                                       , Infrastructure.MessageBoxButton.Ok
                                       , Infrastructure.MessageBoxImage.Warning));
        }
        private void IsCommonWorkspaceEnabledCheckBoxClick(object sender, RoutedEventArgs e)
        {
            IMessageBoxView view = WorkItem.SmartParts.AddNew <MessageBoxView>();

            if (view.Show(StringResources.Settings_PopularCommonWorkspace, StringResources.Settings_CloseAllWindows, null, Infrastructure.MessageBoxButton.YesNo, Infrastructure.MessageBoxImage.Question) == Infrastructure.MessageBoxResult.Yes)
            {
                if (CloseAllWorkspaces != null)
                {
                    CloseAllWorkspaces(this, new EventArgs());
                }
            }
            else
            {
                isCommonWorkspaceEnabledCheckBox.IsChecked = !isCommonWorkspaceEnabledCheckBox.IsChecked;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Handles the <see cref="ILayoutDesignerView.LayoutDelete"/> event.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void HandleLayoutDelete(object sender, LayoutItemEventArgs e)
        {
            IMessageBoxView  messageBox = this.container.Resolve <IMessageBoxView>();
            MessageBoxResult result     = messageBox.Show(string.Format(CultureInfo.InvariantCulture, PresenterResources.ConfirmLayoutDeletion, this.SaveLayoutName()), PresenterResources.MicrosoftWord, MessageBoxViewButtons.YesNo, MessageBoxViewIcon.Warning);

            if (result == MessageBoxResult.Yes)
            {
                int index = 0;
                LayoutInformation[] layouts = this.GetLayoutList().ToArray();
                for (int i = 0; i < layouts.Length; i++)
                {
                    if (e.LayoutItem.Name == layouts[i].Name)
                    {
                        index = i;
                        break;
                    }
                }

                int nextIndex = -1;
                if (index < layouts.Length - 1)
                {
                    nextIndex = index + 1;
                }
                else if (index >= layouts.Length - 1)
                {
                    nextIndex = index - 1;
                }

                this.manager.SystemTemplate.DeleteLayout(e.LayoutItem.Name);
                this.manager.SystemTemplate.Save();
                if (this.CurrentLayoutIsTemporary())
                {
                    this.RemoveTemporaryLayout();
                }

                this.SetDocumentClean();
                this.SetViewLayoutList();

                if (nextIndex != -1)
                {
                    this.ChangeDisplayedLayout(layouts[nextIndex]);
                }

                this.SetEditorControls();
            }
        }
Beispiel #6
0
        private void DispatcherUnhandledExceptionEventHandler(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            Exception ex = e.Exception;

            if (ex is TargetInvocationException)
            {
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
            }

            IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();

            messageBoxView.Show(StringResources.Unhandled_Exception_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
        }
Beispiel #7
0
        public void ActionExecutedEventHandler(object sender, DataEventArgs <ShellDrillDownMenuItem> e)
        {
            ShellDrillDownMenuItem action = e.Data;

            if (!action.IsAuthorized)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.Authorization_NotAuhtorized
                                    , StringResources.Authorization_Message
                                    , null
                                    , Infrastructure.MessageBoxButton.Ok
                                    , Infrastructure.MessageBoxImage.Warning);

                return;
            }
            else if (!action.IsEnabled)
            {
                return;
            }

            try
            {
                _shellView.ShowProgress();

                try
                {
                    IActionCatalogService actionCatalog = action.WorkItem.Services.Get <IActionCatalogService>();
                    actionCatalog.Execute(action.Id, action.WorkItem, this, action.Parameters);
                }
                finally
                {
                    _shellView.HideProgress();
                }
            }
            catch (Exception ex)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
            }
        }
Beispiel #8
0
        public void StartMenuItemExecutedEventHandler(object sender, StartMenuItemExecutedEventArgs e)
        {
            ShellMenuItem shellMenuItem = new ShellMenuItem();

            shellMenuItem.Id           = e.MenuItem.Id;
            shellMenuItem.EventTopic   = e.MenuItem.EventTopic;
            shellMenuItem.Caption      = e.MenuItem.Caption;
            shellMenuItem.IsAuthorized = e.MenuItem.IsAuthorized;
            shellMenuItem.IsEnabled    = e.MenuItem.IsEnabled;
            shellMenuItem.Parameters   = e.MenuItem.Parameters;
            shellMenuItem.Operation    = e.MenuItem.Operation;
            shellMenuItem.AssemblyFile = e.MenuItem.AssemblyFile;

            if (!shellMenuItem.IsAuthorized)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.Authorization_NotAuhtorized
                                    , StringResources.Authorization_Message
                                    , null
                                    , Infrastructure.MessageBoxButton.Ok
                                    , Infrastructure.MessageBoxImage.Warning);

                return;
            }

            try
            {
                _shellView.ShowProgress();

                try
                {
                    if (!string.IsNullOrEmpty(shellMenuItem.AssemblyFile))
                    {
                        ModuleInfo info = new ModuleInfo(shellMenuItem.AssemblyFile);
                        ModuleLoaderService.Load(ShellModuleService.GetWorkItem(e.Module), info);
                    }

                    MenuItemExecutedEventArgs mappedEventArgs = new MenuItemExecutedEventArgs();
                    mappedEventArgs.MenuItem        = shellMenuItem;
                    mappedEventArgs.OpenInNewWindow = (e.StartOption == StartOption.NewWindow || e.StartOption == StartOption.Dashboard);

                    ShellInteractionService interactionService = ShellModuleService.GetWorkItem(e.Module).Services.Get <IShellInteractionService>() as ShellInteractionService;
                    interactionService.OnMenuItemExecuted(mappedEventArgs);

                    if (!string.IsNullOrEmpty(shellMenuItem.EventTopic))
                    {
                        EventTopic itemTopic = WorkItem.RootWorkItem.EventTopics.Get(shellMenuItem.EventTopic);

                        if (itemTopic != null)
                        {
                            itemTopic.Fire(this, mappedEventArgs, WorkItem.RootWorkItem, PublicationScope.Global);
                        }
                    }
                }
                finally
                {
                    _shellView.HideProgress();
                }
            }
            catch (Exception ex)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
            }
        }
        public MessageBoxResult ShowMessageBox(string caption, string message, string details, MessageBoxButton button, MessageBoxImage image)
        {
            IMessageBoxView view = _workItem.SmartParts.AddNew <MessageBoxView>();

            return(view.Show(caption, message, details, button, image));
        }
 /// <summary>
 /// Показать сообщение в диалоге
 /// </summary>
 /// <param name="message"></param>
 public void Show(string message)
 {
     _view.Show(message);
 }
Beispiel #11
0
        /// <summary>
        /// Displays a question to the user which has only a Yes or No answer.
        /// </summary>
        /// <param name="message">The text of the question.</param>
        /// <returns><c>True</c> if the user responds with a Yes, <c>false</c> otherwise.</returns>
        public bool AskYesNoQuestion(string message)
        {
            IMessageBoxView msgbox = this.container.Resolve <IMessageBoxView>();

            return(msgbox.Show(message, PresenterResources.MicrosoftWord, MessageBoxViewButtons.YesNo, MessageBoxViewIcon.Warning) == MessageBoxResult.Yes);
        }