protected override void OnDropDownOpening(EventArgs e) { this.DropDownItems.Clear(); IList <Triple <Assembly, Type, Exception> > pluginLoadErrors = AppWorkspace.GetEffectLoadErrors(); this.DropDownItems.AddRange(GetMenuItemsToAdd(pluginLoadErrors.Count > 0)); this.menuFileNew.Enabled = true; this.menuFileOpen.Enabled = true; this.menuFileOpenRecent.Enabled = true; this.menuFileOpenRecentSentinel.Enabled = true; this.menuFileAcquire.Enabled = true; this.menuFileAcquireFromScannerOrCamera.Enabled = true; this.menuFileExit.Enabled = true; if (AppWorkspace.ActiveDocumentWorkspace != null) { this.menuFileSave.Enabled = true; this.menuFileSaveAs.Enabled = true; this.menuFileClose.Enabled = true; this.menuFilePrint.Enabled = true; } else { this.menuFileSave.Enabled = false; this.menuFileSaveAs.Enabled = false; this.menuFileClose.Enabled = false; this.menuFilePrint.Enabled = false; } base.OnDropDownOpening(e); }
private void MenuFileViewPluginLoadErrors_Click(object sender, EventArgs e) { IList <Triple <Assembly, Type, Exception> > allErrors = AppWorkspace.GetEffectLoadErrors(); IList <Triple <Assembly, Type, Exception> > errors = RemoveDuplicates(allErrors); using (Form errorsDialog = new Form()) { errorsDialog.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileViewPluginLoadErrorsIcon.png").Reference); errorsDialog.Text = PdnResources.GetString("Effects.PluginLoadErrorsDialog.Text"); Label messageLabel = new Label(); messageLabel.Name = "messageLabel"; messageLabel.Text = PdnResources.GetString("Effects.PluginLoadErrorsDialog.Message.Text"); TextBox errorsBox = new TextBox(); errorsBox.Font = new Font(FontFamily.GenericMonospace, errorsBox.Font.Size); errorsBox.ReadOnly = true; errorsBox.Multiline = true; errorsBox.ScrollBars = ScrollBars.Vertical; StringBuilder allErrorsText = new StringBuilder(); string headerTextFormat = PdnResources.GetString("EffectErrorMessage.HeaderFormat"); for (int i = 0; i < errors.Count; ++i) { Assembly assembly = errors[i].First; Type type = errors[i].Second; Exception exception = errors[i].Third; string headerText = string.Format(headerTextFormat, i + 1, errors.Count); string errorText = AppWorkspace.GetLocalizedEffectErrorMessage(assembly, type, exception); allErrorsText.Append(headerText); allErrorsText.Append(Environment.NewLine); allErrorsText.Append(errorText); if (i != errors.Count - 1) { allErrorsText.Append(Environment.NewLine); } } errorsBox.Text = allErrorsText.ToString(); errorsDialog.Layout += delegate(object sender2, LayoutEventArgs e2) { int hMargin = UI.ScaleWidth(8); int vMargin = UI.ScaleHeight(8); int insetWidth = errorsDialog.ClientSize.Width - (hMargin * 2); messageLabel.Location = new Point(hMargin, vMargin); messageLabel.Width = insetWidth; messageLabel.Size = messageLabel.GetPreferredSize(new Size(messageLabel.Width, 1)); errorsBox.Location = new Point(hMargin, messageLabel.Bottom + vMargin); errorsBox.Width = insetWidth; errorsBox.Height = errorsDialog.ClientSize.Height - vMargin - errorsBox.Top; }; errorsDialog.StartPosition = FormStartPosition.CenterParent; errorsDialog.ShowInTaskbar = false; errorsDialog.MinimizeBox = false; errorsDialog.Width *= 2; errorsDialog.Size = UI.ScaleSize(errorsDialog.Size); errorsDialog.Controls.Add(messageLabel); errorsDialog.Controls.Add(errorsBox); errorsDialog.ShowDialog(AppWorkspace); } }