diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs b/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs index 66b8e9b4d..91a7df5f9 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs @@ -88,6 +88,8 @@ private void InitializeComponent() this.rbRecentColors = new System.Windows.Forms.RadioButton(); this.rbStandardColors = new System.Windows.Forms.RadioButton(); this.flpColorPaletteSelection = new System.Windows.Forms.FlowLayoutPanel(); + this.lblName = new System.Windows.Forms.Label(); + this.lblNameValue = new System.Windows.Forms.Label(); this.mbCopy = new ShareX.HelpersLib.MenuButton(); this.cbTransparent = new ShareX.HelpersLib.ColorButton(); this.pbColorPreview = new ShareX.HelpersLib.MyPictureBox(); @@ -551,6 +553,16 @@ private void InitializeComponent() this.flpColorPaletteSelection.Controls.Add(this.rbStandardColors); this.flpColorPaletteSelection.Name = "flpColorPaletteSelection"; // + // lblName + // + resources.ApplyResources(this.lblName, "lblName"); + this.lblName.Name = "lblName"; + // + // lblNameValue + // + resources.ApplyResources(this.lblNameValue, "lblNameValue"); + this.lblNameValue.Name = "lblNameValue"; + // // mbCopy // resources.ApplyResources(this.mbCopy, "mbCopy"); @@ -575,6 +587,7 @@ private void InitializeComponent() this.pbColorPreview.DrawCheckeredBackground = true; resources.ApplyResources(this.pbColorPreview, "pbColorPreview"); this.pbColorPreview.Name = "pbColorPreview"; + this.pbColorPreview.PictureBoxBackColor = System.Drawing.SystemColors.Window; this.pbColorPreview.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbColorPreview_MouseClick); // // colorPicker @@ -590,6 +603,8 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Window; this.CancelButton = this.btnCancel; + this.Controls.Add(this.lblName); + this.Controls.Add(this.lblNameValue); this.Controls.Add(this.flpColorPalette); this.Controls.Add(this.flpColorPaletteSelection); this.Controls.Add(this.btnScreenColorPicker); @@ -726,5 +741,7 @@ private void InitializeComponent() private System.Windows.Forms.RadioButton rbRecentColors; private System.Windows.Forms.RadioButton rbStandardColors; private System.Windows.Forms.FlowLayoutPanel flpColorPaletteSelection; + private System.Windows.Forms.Label lblName; + private System.Windows.Forms.Label lblNameValue; } } \ No newline at end of file diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.cs b/ShareX.HelpersLib/Forms/ColorPickerForm.cs index 1af785e96..936764ed3 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.cs +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.cs @@ -210,6 +210,9 @@ private void UpdateControls(MyColor color, ColorType type) txtDecimal.Text = ColorHelpers.ColorToDecimal(color).ToString(); } + Color knownColor = ColorHelpers.FindClosestKnownColor(color); + lblNameValue.Text = Helpers.GetProperName(knownColor.Name); + controlChangingColor = false; } diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.resx b/ShareX.HelpersLib/Forms/ColorPickerForm.resx index a1e9a46eb..7d95823d9 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.resx +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.resx @@ -145,7 +145,7 @@ $this - 24 + 26 NoControl @@ -172,7 +172,7 @@ $this - 25 + 27 True @@ -181,7 +181,7 @@ NoControl - 312, 240 + 309, 262 26, 13 @@ -202,7 +202,7 @@ $this - 26 + 28 True @@ -211,7 +211,7 @@ NoControl - 312, 216 + 309, 238 32, 13 @@ -232,7 +232,7 @@ $this - 27 + 29 600, 174 @@ -262,7 +262,7 @@ $this - 28 + 30 True @@ -271,7 +271,7 @@ NoControl - 488, 178 + 485, 178 29, 13 @@ -292,7 +292,7 @@ $this - 29 + 31 600, 142 @@ -316,7 +316,7 @@ $this - 30 + 32 600, 108 @@ -340,7 +340,7 @@ $this - 31 + 33 600, 78 @@ -364,7 +364,7 @@ $this - 32 + 34 600, 46 @@ -388,7 +388,7 @@ $this - 33 + 35 True @@ -397,7 +397,7 @@ NoControl - 488, 146 + 485, 146 28, 13 @@ -418,7 +418,7 @@ $this - 34 + 36 True @@ -427,7 +427,7 @@ NoControl - 488, 112 + 485, 112 41, 13 @@ -448,7 +448,7 @@ $this - 35 + 37 True @@ -457,7 +457,7 @@ NoControl - 488, 82 + 485, 82 52, 13 @@ -478,7 +478,7 @@ $this - 36 + 38 True @@ -487,7 +487,7 @@ NoControl - 488, 50 + 485, 50 34, 13 @@ -508,7 +508,7 @@ $this - 37 + 39 True @@ -541,7 +541,7 @@ $this - 38 + 40 True @@ -574,7 +574,7 @@ $this - 39 + 41 True @@ -607,7 +607,7 @@ $this - 40 + 42 408, 78 @@ -631,7 +631,7 @@ $this - 8 + 10 408, 46 @@ -655,7 +655,7 @@ $this - 9 + 11 408, 14 @@ -679,7 +679,7 @@ $this - 10 + 12 408, 174 @@ -703,7 +703,7 @@ $this - 41 + 43 408, 142 @@ -727,7 +727,7 @@ $this - 42 + 44 408, 108 @@ -751,7 +751,7 @@ $this - 43 + 45 True @@ -781,7 +781,7 @@ $this - 11 + 13 True @@ -811,7 +811,7 @@ $this - 12 + 14 True @@ -841,7 +841,7 @@ $this - 13 + 15 True @@ -871,7 +871,7 @@ $this - 44 + 46 True @@ -901,7 +901,7 @@ $this - 45 + 47 True @@ -931,7 +931,7 @@ $this - 46 + 48 True @@ -940,7 +940,7 @@ NoControl - 488, 208 + 485, 208 48, 13 @@ -961,7 +961,7 @@ $this - 22 + 24 600, 204 @@ -988,7 +988,7 @@ $this - 21 + 23 True @@ -1021,7 +1021,7 @@ $this - 20 + 22 True @@ -1054,7 +1054,7 @@ $this - 19 + 21 True @@ -1087,7 +1087,7 @@ $this - 18 + 20 True @@ -1120,7 +1120,7 @@ $this - 17 + 19 600, 14 @@ -1144,7 +1144,7 @@ $this - 16 + 18 True @@ -1153,7 +1153,7 @@ NoControl - 488, 18 + 485, 18 37, 13 @@ -1174,7 +1174,7 @@ $this - 15 + 17 17, 17 @@ -1207,55 +1207,55 @@ $this - 3 + 5 104, 17 - 146, 22 + 147, 22 Copy all - 146, 22 + 147, 22 Copy RGB - 146, 22 + 147, 22 Copy hexadecimal - 146, 22 + 147, 22 Copy CMYK - 146, 22 + 147, 22 Copy HSB - 146, 22 + 147, 22 Copy decimal - 146, 22 + 147, 22 Copy position - 147, 158 + 148, 158 cmsCopy @@ -1384,7 +1384,7 @@ NoControl - 0, 4 + -3, 4 79, 13 @@ -1426,7 +1426,7 @@ $this - 5 + 7 NoControl @@ -1453,7 +1453,7 @@ $this - 4 + 6 8, 293 @@ -1474,7 +1474,7 @@ $this - 1 + 3 True @@ -1561,6 +1561,63 @@ $this + 4 + + + True + + + NoControl + + + 309, 208 + + + 38, 13 + + + 49 + + + Name: + + + lblName + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + NoControl + + + 347, 203 + + + 112, 23 + + + 50 + + + MiddleRight + + + lblNameValue + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 2 @@ -1582,13 +1639,13 @@ mbCopy - ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=13.0.2.0, Culture=neutral, PublicKeyToken=null $this - 6 + 8 NoControl @@ -1609,19 +1666,19 @@ cbTransparent - ShareX.HelpersLib.ColorButton, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.ColorButton, ShareX.HelpersLib, Version=13.0.2.0, Culture=neutral, PublicKeyToken=null $this - 7 + 9 - 376, 208 + 408, 232 - 80, 56 + 48, 48 38 @@ -1630,13 +1687,13 @@ pbColorPreview - ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=13.0.2.0, Culture=neutral, PublicKeyToken=null $this - 14 + 16 True @@ -1654,13 +1711,13 @@ colorPicker - ShareX.HelpersLib.ColorPicker, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.ColorPicker, ShareX.HelpersLib, Version=13.0.2.0, Culture=neutral, PublicKeyToken=null $this - 23 + 25 True @@ -1674,9 +1731,6 @@ 681, 336 - - NoControl - CenterScreen diff --git a/ShareX.HelpersLib/Helpers/ColorHelpers.cs b/ShareX.HelpersLib/Helpers/ColorHelpers.cs index 291d60acd..a9327cfaf 100644 --- a/ShareX.HelpersLib/Helpers/ColorHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ColorHelpers.cs @@ -24,7 +24,9 @@ #endregion License Information (GPL v3) using System; +using System.Collections.Generic; using System.Drawing; +using System.Linq; using System.Text.RegularExpressions; namespace ShareX.HelpersLib @@ -425,5 +427,24 @@ public static Color DarkerColor(Color color, float amount) { return Lerp(color, Color.Black, amount); } + + public static List GetKnownColors() + { + List colors = new List(); + + for (KnownColor knownColor = KnownColor.AliceBlue; knownColor <= KnownColor.YellowGreen; knownColor++) + { + Color color = Color.FromKnownColor(knownColor); + colors.Add(color); + } + + return colors; + } + + public static Color FindClosestKnownColor(Color color) + { + List colors = GetKnownColors(); + return colors.Aggregate(Color.Black, (accu, curr) => ColorDifference(color, curr) < ColorDifference(color, accu) ? curr : accu); + } } } \ No newline at end of file