diff --git a/ShareX.HelpersLib/Colors/ColorPickerForm.Designer.cs b/ShareX.HelpersLib/Colors/ColorPickerForm.Designer.cs index 81135de5e..a634819cf 100644 --- a/ShareX.HelpersLib/Colors/ColorPickerForm.Designer.cs +++ b/ShareX.HelpersLib/Colors/ColorPickerForm.Designer.cs @@ -68,6 +68,7 @@ private void InitializeComponent() this.nudAlpha = new System.Windows.Forms.NumericUpDown(); this.lblAlpha = new System.Windows.Forms.Label(); this.ttMain = new System.Windows.Forms.ToolTip(this.components); + this.cbTransparent = new ShareX.HelpersLib.ColorButton(); this.cmsCopy = new System.Windows.Forms.ContextMenuStrip(this.components); this.tsmiCopyAll = new System.Windows.Forms.ToolStripMenuItem(); this.tsmiCopyRGB = new System.Windows.Forms.ToolStripMenuItem(); @@ -77,17 +78,19 @@ private void InitializeComponent() this.tsmiCopyDecimal = new System.Windows.Forms.ToolStripMenuItem(); this.tsmiCopyPosition = new System.Windows.Forms.ToolStripMenuItem(); this.pSceenColorPicker = new System.Windows.Forms.Panel(); + this.btnPickColor = new System.Windows.Forms.Button(); this.txtY = new System.Windows.Forms.TextBox(); this.txtX = new System.Windows.Forms.TextBox(); this.lblY = new System.Windows.Forms.Label(); this.lblX = new System.Windows.Forms.Label(); this.lblCursorPosition = new System.Windows.Forms.Label(); this.btnClose = new System.Windows.Forms.Button(); - this.btnPickColor = new System.Windows.Forms.Button(); this.mbCopy = new ShareX.HelpersLib.MenuButton(); - this.cbTransparent = new ShareX.HelpersLib.ColorButton(); this.pbColorPreview = new ShareX.HelpersLib.MyPictureBox(); this.colorPicker = new ShareX.HelpersLib.ColorPicker(); + this.pColorPicker = new System.Windows.Forms.Panel(); + this.lblRecentColors = new System.Windows.Forms.Label(); + this.flpRecentColors = new System.Windows.Forms.FlowLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.nudKey)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudYellow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudMagenta)).BeginInit(); @@ -101,6 +104,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.nudAlpha)).BeginInit(); this.cmsCopy.SuspendLayout(); this.pSceenColorPicker.SuspendLayout(); + this.pColorPicker.SuspendLayout(); this.SuspendLayout(); // // btnCancel @@ -410,6 +414,16 @@ private void InitializeComponent() this.ttMain.InitialDelay = 100; this.ttMain.ReshowDelay = 100; // + // cbTransparent + // + this.cbTransparent.Color = System.Drawing.Color.Transparent; + resources.ApplyResources(this.cbTransparent, "cbTransparent"); + this.cbTransparent.ManualButtonClick = true; + this.cbTransparent.Name = "cbTransparent"; + this.ttMain.SetToolTip(this.cbTransparent, resources.GetString("cbTransparent.ToolTip")); + this.cbTransparent.UseVisualStyleBackColor = true; + this.cbTransparent.Click += new System.EventHandler(this.cbTransparent_Click); + // // cmsCopy // this.cmsCopy.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -477,6 +491,13 @@ private void InitializeComponent() resources.ApplyResources(this.pSceenColorPicker, "pSceenColorPicker"); this.pSceenColorPicker.Name = "pSceenColorPicker"; // + // btnPickColor + // + resources.ApplyResources(this.btnPickColor, "btnPickColor"); + this.btnPickColor.Name = "btnPickColor"; + this.btnPickColor.UseVisualStyleBackColor = true; + this.btnPickColor.Click += new System.EventHandler(this.btnPickColor_Click); + // // txtY // resources.ApplyResources(this.txtY, "txtY"); @@ -511,13 +532,6 @@ private void InitializeComponent() this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // - // btnPickColor - // - resources.ApplyResources(this.btnPickColor, "btnPickColor"); - this.btnPickColor.Name = "btnPickColor"; - this.btnPickColor.UseVisualStyleBackColor = true; - this.btnPickColor.Click += new System.EventHandler(this.btnPickColor_Click); - // // mbCopy // resources.ApplyResources(this.mbCopy, "mbCopy"); @@ -525,17 +539,6 @@ private void InitializeComponent() this.mbCopy.Name = "mbCopy"; this.mbCopy.UseVisualStyleBackColor = true; // - // cbTransparent - // - this.cbTransparent.Color = System.Drawing.Color.Transparent; - resources.ApplyResources(this.cbTransparent, "cbTransparent"); - this.cbTransparent.ManualButtonClick = true; - this.cbTransparent.Name = "cbTransparent"; - this.cbTransparent.Offset = 3; - this.ttMain.SetToolTip(this.cbTransparent, resources.GetString("cbTransparent.ToolTip")); - this.cbTransparent.UseVisualStyleBackColor = true; - this.cbTransparent.Click += new System.EventHandler(this.cbTransparent_Click); - // // pbColorPreview // this.pbColorPreview.BackColor = System.Drawing.SystemColors.Window; @@ -552,12 +555,30 @@ private void InitializeComponent() this.colorPicker.Name = "colorPicker"; this.colorPicker.ColorChanged += new ShareX.HelpersLib.ColorEventHandler(this.colorPicker_ColorChanged); // + // pColorPicker + // + this.pColorPicker.Controls.Add(this.lblRecentColors); + this.pColorPicker.Controls.Add(this.flpRecentColors); + resources.ApplyResources(this.pColorPicker, "pColorPicker"); + this.pColorPicker.Name = "pColorPicker"; + // + // lblRecentColors + // + resources.ApplyResources(this.lblRecentColors, "lblRecentColors"); + this.lblRecentColors.Name = "lblRecentColors"; + // + // flpRecentColors + // + resources.ApplyResources(this.flpRecentColors, "flpRecentColors"); + this.flpRecentColors.Name = "flpRecentColors"; + // // ColorPickerForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.SystemColors.Window; this.CancelButton = this.btnCancel; resources.ApplyResources(this, "$this"); + this.Controls.Add(this.pColorPicker); this.Controls.Add(this.btnClose); this.Controls.Add(this.pSceenColorPicker); this.Controls.Add(this.mbCopy); @@ -619,6 +640,8 @@ private void InitializeComponent() this.cmsCopy.ResumeLayout(false); this.pSceenColorPicker.ResumeLayout(false); this.pSceenColorPicker.PerformLayout(); + this.pColorPicker.ResumeLayout(false); + this.pColorPicker.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -684,5 +707,8 @@ private void InitializeComponent() private System.Windows.Forms.TextBox txtY; private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnPickColor; + private System.Windows.Forms.Panel pColorPicker; + private System.Windows.Forms.FlowLayoutPanel flpRecentColors; + private System.Windows.Forms.Label lblRecentColors; } } \ No newline at end of file diff --git a/ShareX.HelpersLib/Colors/ColorPickerForm.cs b/ShareX.HelpersLib/Colors/ColorPickerForm.cs index b70326b6e..089744e18 100644 --- a/ShareX.HelpersLib/Colors/ColorPickerForm.cs +++ b/ShareX.HelpersLib/Colors/ColorPickerForm.cs @@ -50,8 +50,13 @@ public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false) SetCurrentColor(currentColor, !IsScreenColorPickerMode); - btnOK.Visible = btnCancel.Visible = !IsScreenColorPickerMode; + btnOK.Visible = btnCancel.Visible = pColorPicker.Visible = !IsScreenColorPickerMode; mbCopy.Visible = btnClose.Visible = pSceenColorPicker.Visible = IsScreenColorPickerMode; + + if (!IsScreenColorPickerMode) + { + PrepareRecentColors(); + } } public void EnableScreenColorPickerButton(Func openScreenColorPicker) @@ -75,6 +80,26 @@ public static bool PickColor(Color currentColor, out Color newColor) return false; } + private void PrepareRecentColors() + { + for (int i = 0; i < 32; i++) + { + ColorButton colorButton = new ColorButton() + { + Color = new HSB(i / 32d, 1d, 1d), + Size = new Size(16, 16), + Offset = 2, + Margin = new Padding(0), + ManualButtonClick = true + }; + + colorButton.Click += (sender, e) => SetCurrentColor(colorButton.Color, true); + + flpRecentColors.Controls.Add(colorButton); + if ((i + 1) % 16 == 0) flpRecentColors.SetFlowBreak(colorButton, true); + } + } + public void SetCurrentColor(Color currentColor, bool keepPreviousColor) { oldColorExist = keepPreviousColor; diff --git a/ShareX.HelpersLib/Colors/ColorPickerForm.resx b/ShareX.HelpersLib/Colors/ColorPickerForm.resx index 8eab2202c..32ba218b9 100644 --- a/ShareX.HelpersLib/Colors/ColorPickerForm.resx +++ b/ShareX.HelpersLib/Colors/ColorPickerForm.resx @@ -123,7 +123,7 @@ - 560, 232 + 560, 288 72, 32 @@ -145,13 +145,13 @@ $this - 21 + 22 NoControl - 480, 232 + 480, 288 72, 32 @@ -172,7 +172,7 @@ $this - 22 + 23 True @@ -202,7 +202,7 @@ $this - 23 + 24 True @@ -232,7 +232,7 @@ $this - 24 + 25 560, 174 @@ -262,7 +262,7 @@ $this - 25 + 26 True @@ -292,7 +292,7 @@ $this - 26 + 27 560, 142 @@ -316,7 +316,7 @@ $this - 27 + 28 560, 108 @@ -340,7 +340,7 @@ $this - 28 + 29 560, 78 @@ -364,7 +364,7 @@ $this - 29 + 30 560, 46 @@ -388,7 +388,7 @@ $this - 30 + 31 True @@ -418,7 +418,7 @@ $this - 31 + 32 True @@ -448,7 +448,7 @@ $this - 32 + 33 True @@ -478,7 +478,7 @@ $this - 33 + 34 True @@ -508,7 +508,7 @@ $this - 34 + 35 True @@ -541,7 +541,7 @@ $this - 35 + 36 True @@ -574,7 +574,7 @@ $this - 36 + 37 True @@ -607,7 +607,7 @@ $this - 37 + 38 408, 78 @@ -631,7 +631,7 @@ $this - 5 + 6 408, 46 @@ -655,7 +655,7 @@ $this - 6 + 7 408, 14 @@ -679,7 +679,7 @@ $this - 7 + 8 408, 174 @@ -703,7 +703,7 @@ $this - 38 + 39 408, 142 @@ -727,7 +727,7 @@ $this - 39 + 40 408, 108 @@ -751,7 +751,7 @@ $this - 40 + 41 True @@ -781,7 +781,7 @@ $this - 8 + 9 True @@ -811,7 +811,7 @@ $this - 9 + 10 True @@ -841,7 +841,7 @@ $this - 10 + 11 True @@ -871,7 +871,7 @@ $this - 41 + 42 True @@ -901,7 +901,7 @@ $this - 42 + 43 True @@ -931,7 +931,7 @@ $this - 43 + 44 True @@ -961,7 +961,7 @@ $this - 19 + 20 560, 204 @@ -988,7 +988,7 @@ $this - 18 + 19 True @@ -1021,7 +1021,7 @@ $this - 17 + 18 True @@ -1054,7 +1054,7 @@ $this - 16 + 17 True @@ -1087,7 +1087,7 @@ $this - 15 + 16 True @@ -1120,7 +1120,7 @@ $this - 14 + 15 560, 14 @@ -1144,7 +1144,7 @@ $this - 13 + 14 True @@ -1174,11 +1174,38 @@ $this - 12 + 13 17, 17 + + NoControl + + + 612, 13 + + + 23, 23 + + + 39 + + + Transparent + + + cbTransparent + + + ShareX.HelpersLib.ColorButton, ShareX.HelpersLib, Version=12.2.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 5 + 104, 17 @@ -1233,6 +1260,99 @@ Copy position + + btnPickColor + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pSceenColorPicker + + + 0 + + + txtY + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pSceenColorPicker + + + 1 + + + txtX + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pSceenColorPicker + + + 2 + + + lblY + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pSceenColorPicker + + + 3 + + + lblX + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pSceenColorPicker + + + 4 + + + lblCursorPosition + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pSceenColorPicker + + + 5 + + + 8, 272 + + + 296, 56 + + + 42 + + + pSceenColorPicker + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + NoControl @@ -1404,32 +1524,11 @@ 5 - - 8, 272 - - - 296, 56 - - - 42 - - - pSceenColorPicker - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - NoControl - 560, 232 + 560, 288 72, 32 @@ -1450,13 +1549,13 @@ $this - 1 + 2 NoControl - 472, 232 + 472, 288 80, 32 @@ -1477,33 +1576,6 @@ $this - 3 - - - NoControl - - - 612, 13 - - - 23, 23 - - - 39 - - - Transparent - - - cbTransparent - - - ShareX.HelpersLib.ColorButton, ShareX.HelpersLib, Version=12.2.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - 4 @@ -1525,7 +1597,7 @@ $this - 11 + 12 True @@ -1549,16 +1621,106 @@ $this - 20 + 21 + + + lblRecentColors + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pColorPicker + + + 0 + + + flpRecentColors + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pColorPicker + + + 1 + + + 8, 271 + + + 296, 56 + + + 44 + + + pColorPicker + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + -3, 0 + + + 76, 13 + + + 45 + + + Recent colors: + + + lblRecentColors + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pColorPicker + + + 0 + + + 0, 16 + + + 296, 40 + + + 0 + + + flpRecentColors + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pColorPicker + + + 1 True - 642, 327 - - - NoControl + 640, 328 CenterScreen diff --git a/ShareX.HelpersLib/Controls/ColorButton.cs b/ShareX.HelpersLib/Controls/ColorButton.cs index dde6fc652..c592cf081 100644 --- a/ShareX.HelpersLib/Controls/ColorButton.cs +++ b/ShareX.HelpersLib/Controls/ColorButton.cs @@ -51,6 +51,7 @@ public Color Color } } + [DefaultValue(3)] public int Offset { get; set; } = 3; [DefaultValue(false)]