FEATURE-1196 (#339)

* FEATURE-1196: Double clicking on the colour square chooses the color and closes the color window
* BUG-2565: Tooltip on recent colors is not representing the color.
This commit is contained in:
Eric Cogen 2021-10-13 02:18:13 -04:00 committed by GitHub
commit e06c3e8510
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View file

@ -0,0 +1,12 @@
using System.Windows.Forms;
namespace Greenshot.Base.Controls
{
public class GreenshotDoubleClickButton : Button
{
public GreenshotDoubleClickButton()
{
SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true);
}
}
}

View file

@ -21,10 +21,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using Greenshot.Base.Controls;
using Greenshot.Base.IniFile; using Greenshot.Base.IniFile;
using Greenshot.Editor.Configuration; using Greenshot.Editor.Configuration;
using Greenshot.Editor.Controls; using Greenshot.Editor.Controls;
@ -114,7 +116,7 @@ namespace Greenshot.Editor.Forms
private Button CreateColorButton(Color color, int x, int y, int w, int h) private Button CreateColorButton(Color color, int x, int y, int w, int h)
{ {
Button b = new Button Button b = new GreenshotDoubleClickButton
{ {
BackColor = color, BackColor = color,
FlatStyle = FlatStyle.Flat, FlatStyle = FlatStyle.Flat,
@ -124,10 +126,17 @@ namespace Greenshot.Editor.Forms
}; };
b.FlatAppearance.BorderSize = 0; b.FlatAppearance.BorderSize = 0;
b.Click += ColorButtonClick; b.Click += ColorButtonClick;
_toolTip.SetToolTip(b, ColorTranslator.ToHtml(color) + " | R:" + color.R + ", G:" + color.G + ", B:" + color.B); b.DoubleClick += ColorButtonDoubleClick;
SetButtonTooltip(b, color);
return b; return b;
} }
private void ColorButtonDoubleClick(object sender, EventArgs e)
{
ColorButtonClick(sender, e);
BtnApplyClick(sender, e);
}
private void CreateLastUsedColorButtonRow(int x, int y, int w, int h) private void CreateLastUsedColorButtonRow(int x, int y, int w, int h)
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
@ -147,6 +156,7 @@ namespace Greenshot.Editor.Forms
{ {
_recentColorButtons[i].BackColor = EditorConfig.RecentColors[i]; _recentColorButtons[i].BackColor = EditorConfig.RecentColors[i];
_recentColorButtons[i].Enabled = true; _recentColorButtons[i].Enabled = true;
SetButtonTooltip(_recentColorButtons[i], EditorConfig.RecentColors[i]);
} }
} }
@ -245,6 +255,11 @@ namespace Greenshot.Editor.Forms
PreviewColor(b.BackColor, b); PreviewColor(b.BackColor, b);
} }
private void SetButtonTooltip(Button colorButton, Color color)
{
_toolTip.SetToolTip(colorButton, ColorTranslator.ToHtml(color) + " | R:" + color.R + ", G:" + color.G + ", B:" + color.B);
}
private void BtnTransparentClick(object sender, EventArgs e) private void BtnTransparentClick(object sender, EventArgs e)
{ {
ColorButtonClick(sender, e); ColorButtonClick(sender, e);