public SettingsDialog(IServiceProvider services, AppSettings appSettings, AppSettings.ToolsSection toolBarSettings) { Validate.Begin().IsNotNull <IServiceProvider>(services, "services").IsNotNull <AppSettings>(appSettings, "appSettings").IsNotNull <AppSettings.ToolsSection>(toolBarSettings, "toolBarSettings").Check(); this.services = services; this.appSettings = appSettings; this.toolBarSettings = toolBarSettings; this.components = new Container(); List <SettingsDialogSection> items = new List <SettingsDialogSection> { new UISettingsSection(this.appSettings), new ToolsSettingsSection(this.appSettings, toolBarSettings) }; if (!WinAppModel.HasCurrentPackage) { items.Add(new UpdatesSettingsSection(this, this.appSettings)); } items.Add(new DiagnosticsSettingsSection(this.appSettings)); IPluginErrorService pluginErrorService = services.GetService <IPluginErrorService>(); if (pluginErrorService.GetPluginLoadErrors().Any <PluginErrorInfo>()) { items.Add(new PluginsSettingsSection(this.appSettings, pluginErrorService)); } this.settingsSections = items.ToArrayEx <SettingsDialogSection>(); this.settingsPages = this.settingsSections.Select <SettingsDialogSection, SettingsDialogPage>(ss => ss.CreateUI()).ToArrayEx <SettingsDialogPage>(); if (lastCurrentSection == null) { this.currentSection = this.settingsSections[0]; } else { this.currentSection = this.settingsSections.FirstOrDefault <SettingsDialogSection>(ss => (ss.GetType() == lastCurrentSection)) ?? this.settingsSections[0]; } base.SuspendLayout(); this.DoubleBuffered = true; base.ResizeRedraw = true; base.AutoHandleGlassRelatedOptimizations = true; base.IsGlassDesired = !OS.IsWin10OrLater; this.Font = System.Drawing.SystemFonts.MenuFont; this.sectionsListBox = new FlickerFreeOwnerDrawListBox(); this.sectionPanel = new PanelEx(); this.separator = new PaintDotNet.Controls.SeparatorLine(); this.closeButton = new PdnPushButton(); this.closeButton.Name = "closeButton"; this.closeButton.AutoSize = true; this.closeButton.Text = PdnResources.GetString("Form.CloseButton.Text"); this.sectionPanel.Name = "sectionPanel"; this.sectionPanel.AutoScroll = true; this.sectionPanel.HideHScroll = true; this.sectionPanel.HorizontalScroll.Enabled = false; this.sectionPanel.HorizontalScroll.Visible = false; this.sectionPanel.VerticalScroll.Enabled = true; this.sectionsListBox.Name = "sectionsListBox"; this.sectionsListBox.Items.AddRange(this.settingsSections.ToArrayEx <SettingsDialogSection>()); this.sectionsListBox.DrawMode = DrawMode.OwnerDrawFixed; this.sectionsListBox.ItemHeight = UIUtil.ScaleHeight(0x20); this.sectionsListBox.DrawItem += new DrawItemEventHandler(this.OnSectionsListBoxDrawItem); this.sectionsListBox.IntegralHeight = false; this.sectionsListBox.BorderStyle = BorderStyle.FixedSingle; this.sectionsListBox.MouseEnter += (s, e) => this.UpdateHotTrackIndex(new Point(-1, -1)); this.sectionsListBox.MouseMove += (s, e) => this.UpdateHotTrackIndex(e.Location); this.sectionsListBox.MouseLeave += (s, e) => this.UpdateHotTrackIndex(new Point(-1, -1)); this.sectionsListBox.SelectedIndex = this.settingsSections.IndexOf <SettingsDialogSection>(this.currentSection); this.sectionsListBox.SelectedIndexChanged += new EventHandler(this.OnSectionsListBoxSelectedIndexChanged); this.separator.Name = "separator"; base.Controls.Add(this.sectionsListBox); base.Controls.Add(this.sectionPanel); base.Controls.Add(this.closeButton); base.Controls.Add(this.separator); base.Icon = PdnResources.GetImageResource("Icons.MenuUtilitiesSettingsIcon.png").Reference.ToIcon(); base.AcceptButton = this.closeButton; base.CancelButton = this.closeButton; base.MinimizeBox = false; base.MaximizeBox = false; base.StartPosition = FormStartPosition.CenterParent; base.FormBorderStyle = FormBorderStyle.Sizable; base.ShowInTaskbar = false; this.Text = PdnResources.GetString("SettingsDialog.Text"); base.ClientSize = UIUtil.ScaleSize(600, 450); base.ResumeLayout(false); base.PerformLayout(); }
public PluginsSettingsSection(AppSettings appSettings, IPluginErrorService pluginErrorService) : base(appSettings, PdnResources.GetString("SettingsDialog.Plugins.DisplayName"), PdnResources.GetImageResource("Icons.Settings.Plugins.24.png").Reference) { Validate.IsNotNull <IPluginErrorService>(pluginErrorService, "pluginErrorService"); this.pluginErrorService = pluginErrorService; }
private static string GetDetailTextForFilePath(IPluginErrorService pluginErrorService, IEnumerable <PluginErrorInfo> allPluginErrorInfos, string filePath) { string format = PdnResources.GetString("SettingsDialog.Plugins.AssemblyDetailText.Name.Format"); string str2 = PdnResources.GetString("SettingsDialog.Plugins.SupportInfo.DisplayName.Format"); string str3 = PdnResources.GetString("SettingsDialog.Plugins.SupportInfo.Version.Format"); string str4 = PdnResources.GetString("SettingsDialog.Plugins.SupportInfo.Author.Format"); string str5 = PdnResources.GetString("SettingsDialog.Plugins.SupportInfo.Copyright.Format"); string str6 = PdnResources.GetString("SettingsDialog.Plugins.SupportInfo.Website.Format"); string str7 = PdnResources.GetString("SettingsDialog.Plugins.SupportInfo.Type.Format"); if (((allPluginErrorInfos == null) || !allPluginErrorInfos.Any <PluginErrorInfo>()) || (filePath == null)) { return(string.Empty); } string str8 = null; IPluginSupportInfo pluginSupportInfo = null; if (str8 == null) { Assembly assembly = (from pei in allPluginErrorInfos where pei.FilePath == filePath where pei.HasAssembly select pei.Assembly).FirstOrDefault <Assembly>(); if (assembly != null) { AssemblyName name = new AssemblyName(assembly.FullName); pluginSupportInfo = PluginSupportInfo.GetPluginSupportInfo(assembly); str8 = string.Format(format, assembly.Location, name.Version); } } if (str8 == null) { str8 = filePath; pluginSupportInfo = null; } StringBuilder builder = new StringBuilder(); builder.Append(str8); builder.Append("\r\n"); if (pluginSupportInfo != null) { if (!string.IsNullOrWhiteSpace(pluginSupportInfo.DisplayName)) { builder.AppendFormat(str2, pluginSupportInfo.DisplayName); builder.Append("\r\n"); } if ((pluginSupportInfo.Version != null) && (pluginSupportInfo.Version != new Version(0, 0, 0, 0))) { builder.AppendFormat(str3, pluginSupportInfo.Version.ToString()); builder.Append("\r\n"); } if (!string.IsNullOrWhiteSpace(pluginSupportInfo.Author)) { builder.AppendFormat(str4, pluginSupportInfo.Author); builder.Append("\r\n"); } if (!string.IsNullOrWhiteSpace(pluginSupportInfo.Copyright)) { builder.AppendFormat(str5, pluginSupportInfo.Copyright); builder.Append("\r\n"); } if (pluginSupportInfo.WebsiteUri != null) { builder.AppendFormat(str6, pluginSupportInfo.WebsiteUri.ToString()); builder.Append("\r\n"); } } builder.Append("\r\n"); PluginErrorInfo[] infoArray = (from pei in allPluginErrorInfos where pei.FilePath == filePath orderby pei.TypeName select pei).ToArrayEx <PluginErrorInfo>(); bool flag = true; foreach (PluginErrorInfo info2 in infoArray) { IPluginSupportInfo info3; string pluginBlockReasonString; if (!flag) { builder.Append("\r\n"); } else { flag = false; } if (info2.Type != null) { info3 = PluginSupportInfo.GetPluginSupportInfo(info2.Type); } else { info3 = null; } if ((info3 != null) && !string.IsNullOrWhiteSpace(info3.DisplayName)) { builder.AppendFormat(str2, info3.DisplayName); builder.Append("\r\n"); } if (info2.HasTypeName) { builder.AppendFormat(str7, info2.TypeName); builder.Append("\r\n"); } if (info3 != null) { if ((info3.Version != null) && (info3.Version != new Version(0, 0, 0, 0))) { builder.AppendFormat(str3, info3.Version.ToString()); builder.Append("\r\n"); } if (!string.IsNullOrWhiteSpace(info3.Author)) { builder.AppendFormat(str4, info3.Author); builder.Append("\r\n"); } if (!string.IsNullOrWhiteSpace(info3.Copyright)) { builder.AppendFormat(str5, info3.Copyright); builder.Append("\r\n"); } if (info3.WebsiteUri != null) { builder.AppendFormat(str6, info3.WebsiteUri.ToString()); builder.Append("\r\n"); } } if (info2.Error is BlockedPluginException) { pluginBlockReasonString = GetPluginBlockReasonString(((BlockedPluginException)info2.Error).Reason); } else { pluginBlockReasonString = info2.ErrorString; } builder.Append(pluginBlockReasonString); builder.Append("\r\n"); } return(builder.ToString()); }