public static void LoadFrom(this AppSettings.ToolsSection dstSettings, AppSettings.ToolsSection srcSettings) { Validate.IsNotNull <AppSettings.ToolsSection>(srcSettings, "srcSettings"); if (dstSettings != srcSettings) { string[] pathComponents = SettingPath.GetPathComponents(dstSettings.Path); string[] strArray2 = SettingPath.GetPathComponents(srcSettings.Path); foreach (Setting setting in dstSettings.Settings) { string[] strArray3 = SettingPath.GetPathComponents(setting.Path); string[] strArray4 = new string[(strArray3.Length - pathComponents.Length) + strArray2.Length]; int index = 0; for (int i = 0; i < strArray2.Length; i++) { strArray4[index] = strArray2[i]; index++; } for (int j = pathComponents.Length; j < strArray3.Length; j++) { strArray4[index] = strArray3[j]; index++; } string str3 = SettingPath.CombinePathComponents(strArray4); Setting setting2 = srcSettings[str3]; setting.Value = setting2.Value; } } }
public ToolsSettingsSection(AppSettings appSettings, AppSettings.ToolsSection toolBarSettings) : base(appSettings, PdnResources.GetString("SettingsDialog.Tools.DisplayName"), PdnResources.GetImageResource("Icons.Settings.Tools.24.png").Reference) { this.toolBarSettings = toolBarSettings; foreach (Setting setting in appSettings.ToolDefaults.Settings) { base.AddSetting(setting); } }
public static System.Drawing.Brush CreateGdipBrush(this AppSettings.ToolsSection toolSettings, bool swapColors) { ColorBgra32 a = toolSettings.PrimaryColor.Value; ColorBgra32 b = toolSettings.SecondaryColor.Value; if (swapColors) { ObjectUtil.Swap <ColorBgra32>(ref a, ref b); } return(toolSettings.CreateGdipBrush(a, b)); }
public static PaintDotNet.UI.Media.Brush CreateBrush(this AppSettings.ToolsSection toolSettings, bool swapColors) { ColorBgra32 a = toolSettings.PrimaryColor.Value; ColorBgra32 b = toolSettings.SecondaryColor.Value; if (swapColors) { ObjectUtil.Swap <ColorBgra32>(ref a, ref b); } return(toolSettings.CreateBrush(a, b)); }
public static System.Drawing.Brush CreateGdipBrush(this AppSettings.ToolsSection toolSettings, ColorBgra32 foreColor, ColorBgra32 backColor) { PaintDotNet.BrushType type = toolSettings.Brush.Type.Value; System.Drawing.Drawing2D.HatchStyle hatchstyle = toolSettings.Brush.HatchStyle.Value; switch (type) { case PaintDotNet.BrushType.Solid: return(new SolidBrush((Color)foreColor)); case PaintDotNet.BrushType.Hatch: return(new System.Drawing.Drawing2D.HatchBrush(hatchstyle, (Color)foreColor, (Color)backColor)); } throw new InvalidOperationException("BrushType is invalid"); }
public static PaintDotNet.UI.Media.Brush CreateBrush(this AppSettings.ToolsSection toolSettings, ColorBgra32 foreColor, ColorBgra32 backColor) { PaintDotNet.BrushType type = toolSettings.Brush.Type.Value; PaintDotNet.UI.Media.HatchStyle hatchStyle = toolSettings.Brush.HatchStyle.Value; switch (type) { case PaintDotNet.BrushType.Solid: return(new SolidColorBrush((ColorRgba128Float)foreColor)); case PaintDotNet.BrushType.Hatch: return(new PaintDotNet.UI.Media.HatchBrush(hatchStyle, (ColorRgba128Float)foreColor, (ColorRgba128Float)backColor)); } throw new InvalidOperationException("BrushType is invalid"); }
public static SizedFontProperties CreateSizedFontProperties(this AppSettings.ToolsSection toolSettings, IFontMap fontMap) { FontProperties fontProperties; FontWeight bold; PaintDotNet.DirectWrite.FontStyle italic; string displayName = toolSettings.Text.FontFamilyName.Value; string[] namesToTry = new string[] { displayName, "Segoe UI", "Arial" }; try { fontProperties = fontMap.GetFontProperties(namesToTry); } catch (NoFontException) { fontProperties = new FontProperties(displayName, string.Empty, FontWeight.Normal, FontStretch.Normal, PaintDotNet.DirectWrite.FontStyle.Normal, TextDecorations.None); } System.Drawing.FontStyle style = toolSettings.Text.FontStyle.Value; FontWeight weight = fontProperties.Weight; if (style.HasFlag(System.Drawing.FontStyle.Bold) && (weight <= FontWeight.DemiBold)) { bold = FontWeight.Bold; } else { bold = weight; } FontStretch stretch = fontProperties.Stretch; PaintDotNet.DirectWrite.FontStyle style2 = fontProperties.Style; if (style.HasFlag(System.Drawing.FontStyle.Italic) && (style2 == PaintDotNet.DirectWrite.FontStyle.Normal)) { italic = PaintDotNet.DirectWrite.FontStyle.Italic; } else { italic = style2; } TextDecorations decorations = (fontProperties.Decorations | (style.HasFlag(System.Drawing.FontStyle.Underline) ? TextDecorations.Underline : TextDecorations.None)) | (style.HasFlag(System.Drawing.FontStyle.Strikeout) ? TextDecorations.Strikethrough : TextDecorations.None); float dipSize = (toolSettings.Text.FontSize.Value * 96f) / 72f; return(new SizedFontProperties(new FontProperties(fontProperties.DisplayName, fontProperties.FontFamilyName, bold, stretch, italic, decorations), dipSize)); }
public ToolConfigRow(AppSettings.ToolsSection toolSettings, PaintDotNet.ToolBarConfigItems toolBarConfigItems) { Validate.IsNotNull <AppSettings.ToolsSection>(toolSettings, "toolSettings"); this.toolSettings = toolSettings; this.toolBarConfigItems = toolBarConfigItems; this.headerLabel = new HeadingLabel(); this.headerLabel.Name = "headerLabel:" + toolBarConfigItems.ToString(); string str2 = PdnResources.GetString(this.GetHeaderResourceName()); this.headerLabel.Text = str2; this.headerLabel.RightMargin = 0; this.toolConfigStrip = new PaintDotNet.Controls.ToolConfigStrip(toolSettings); this.toolConfigStrip.Name = "toolConfigStrip:" + toolBarConfigItems.ToString(); this.toolConfigStrip.AutoSize = false; this.toolConfigStrip.Dock = DockStyle.None; this.toolConfigStrip.GripStyle = ToolStripGripStyle.Hidden; this.toolConfigStrip.LayoutStyle = ToolStripLayoutStyle.Flow; this.toolConfigStrip.ToolBarConfigItems = this.toolBarConfigItems; this.toolConfigStrip.ShowFirstAndLastSeparators = false; }
public static System.Drawing.Pen CreatePen(this AppSettings.ToolsSection toolSettings, ColorBgra32 foreColor, ColorBgra32 backColor) { System.Drawing.Pen pen; LineCap cap3; CustomLineCap cap4; LineCap cap5; CustomLineCap cap6; float width = toolSettings.Pen.Width.Value; LineCap2 cap = toolSettings.Pen.StartCap.Value; LineCap2 cap2 = toolSettings.Pen.EndCap.Value; System.Drawing.Drawing2D.DashStyle style = toolSettings.Pen.DashStyle.Value; if (((PaintDotNet.BrushType)toolSettings.Brush.Type.Value) == PaintDotNet.BrushType.None) { pen = new System.Drawing.Pen((Color)foreColor, width); } else { pen = new System.Drawing.Pen(toolSettings.CreateGdipBrush(foreColor, backColor), width); } LineCapToLineCap2(cap, out cap3, out cap4); if (cap4 != null) { pen.CustomStartCap = cap4; } else { pen.StartCap = cap3; } LineCapToLineCap2(cap2, out cap5, out cap6); if (cap6 != null) { pen.CustomEndCap = cap6; } else { pen.EndCap = cap5; } pen.DashStyle = style; return(pen); }
public ToolsSettingsPage(ToolsSettingsSection section) : base(section) { this.toolType = PaintDotNet.Tools.Tool.DefaultToolType; this.toolConfigRows = new List <ToolConfigRow>(); this.toolSettings = section.AppSettings.ToolDefaults; }
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 ToolSettings(SettingsStorageHandler storageHandler) : base(storageHandler) { this.Tools = base.RegisterSectionDuringCtor <AppSettings.ToolsSection>(new AppSettings.ToolsSection("Tools")); base.EndInit(); }