From c3cd00b482c17cf5ad6902fa17475843a4d05d78 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 2 Jun 2018 01:23:10 +0200 Subject: [PATCH] Small fix for the color dialog, this is still WIP --- .../Controls/ColorDialog.Designer.cs | 15 +++++++++------ src/Greenshot.Addons/Controls/ColorDialog.cs | 17 +++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Greenshot.Addons/Controls/ColorDialog.Designer.cs b/src/Greenshot.Addons/Controls/ColorDialog.Designer.cs index 09b6abfb7..33557b854 100644 --- a/src/Greenshot.Addons/Controls/ColorDialog.Designer.cs +++ b/src/Greenshot.Addons/Controls/ColorDialog.Designer.cs @@ -19,6 +19,8 @@ * along with this program. If not, see . */ +using Dapplo.Windows.Dpi; + namespace Greenshot.Addons.Controls { public partial class ColorDialog { /// @@ -37,7 +39,6 @@ namespace Greenshot.Addons.Controls { components.Dispose(); } } - _dpiSubscription.Dispose(); base.Dispose(disposing); } @@ -48,6 +49,8 @@ namespace Greenshot.Addons.Controls { /// private void InitializeComponent() { + float fontSize = (float) DpiHandler.ScaleWithDpi(11d, DpiHandler.DefaultScreenDpi); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)); this.btnTransparent = new GreenshotButton(); this.colorPanel = new System.Windows.Forms.Panel(); @@ -89,7 +92,7 @@ namespace Greenshot.Addons.Controls { // // labelHtmlColor // - this.labelHtmlColor.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); + this.labelHtmlColor.Font = new System.Drawing.Font("Tahoma", fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); this.labelHtmlColor.LanguageKey = "colorpicker_htmlcolor"; this.labelHtmlColor.Location = new System.Drawing.Point(210, 57); this.labelHtmlColor.Name = "labelHtmlColor"; @@ -110,7 +113,7 @@ namespace Greenshot.Addons.Controls { // // labelRed // - this.labelRed.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); + this.labelRed.Font = new System.Drawing.Font("Tahoma", fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); this.labelRed.LanguageKey = "colorpicker_red"; this.labelRed.Location = new System.Drawing.Point(210, 98); this.labelRed.Name = "labelRed"; @@ -120,7 +123,7 @@ namespace Greenshot.Addons.Controls { // // labelGreen // - this.labelGreen.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); + this.labelGreen.Font = new System.Drawing.Font("Tahoma", fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); this.labelGreen.LanguageKey = "colorpicker_green"; this.labelGreen.Location = new System.Drawing.Point(210, 122); this.labelGreen.Name = "labelGreen"; @@ -130,7 +133,7 @@ namespace Greenshot.Addons.Controls { // // labelBlue // - this.labelBlue.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); + this.labelBlue.Font = new System.Drawing.Font("Tahoma", fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); this.labelBlue.LanguageKey = "colorpicker_blue"; this.labelBlue.Location = new System.Drawing.Point(210, 146); this.labelBlue.Name = "labelBlue"; @@ -197,7 +200,7 @@ namespace Greenshot.Addons.Controls { // // labelAlpha // - this.labelAlpha.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); + this.labelAlpha.Font = new System.Drawing.Font("Tahoma", fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); this.labelAlpha.LanguageKey = "colorpicker_alpha"; this.labelAlpha.Location = new System.Drawing.Point(210, 170); this.labelAlpha.Name = "labelAlpha"; diff --git a/src/Greenshot.Addons/Controls/ColorDialog.cs b/src/Greenshot.Addons/Controls/ColorDialog.cs index 558507f67..e2c25f098 100644 --- a/src/Greenshot.Addons/Controls/ColorDialog.cs +++ b/src/Greenshot.Addons/Controls/ColorDialog.cs @@ -43,23 +43,17 @@ namespace Greenshot.Addons.Controls { private readonly ToolTip _toolTip = new ToolTip(); private bool _updateInProgress; - private readonly IDisposable _dpiSubscription; public ColorDialog(IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage) { - SuspendLayout(); - InitializeComponent(); - ResumeLayout(); - - _dpiSubscription = FormDpiHandler.OnDpiChangeInfo.Subscribe(info => - { - Redraw(); - }); - Redraw(); + SuspendLayout(); + InitializeComponent(); + ResumeLayout(); //UpdateRecentColorsButtonRow(); + Load += (sender, args) => DrawButtons(); } - private void Redraw() + private void DrawButtons() { int pos = FormDpiHandler.ScaleWithCurrentDpi(5); int size = FormDpiHandler.ScaleWithCurrentDpi(15); @@ -67,7 +61,6 @@ namespace Greenshot.Addons.Controls var buttons = CreateColorPalette(pos, pos, size, size); var lastUsedButtons = CreateLastUsedColorButtonRow(pos, lastColorY, size, size); SuspendLayout(); - Controls.Clear(); Controls.AddRange(buttons.ToArray()); Controls.AddRange(lastUsedButtons.ToArray()); ResumeLayout();