mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
fixed #3938: Double clicking recent color box will close color picker dialog
This commit is contained in:
parent
a110f8d582
commit
44a1234c59
1 changed files with 29 additions and 4 deletions
|
@ -85,6 +85,8 @@ private void PrepareRecentColors()
|
|||
{
|
||||
int length = Math.Min(HelpersOptions.RecentColors.Count, HelpersOptions.RecentColorsMax);
|
||||
|
||||
Color previousColor = Color.Empty;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
ColorButton colorButton = new ColorButton()
|
||||
|
@ -98,7 +100,25 @@ private void PrepareRecentColors()
|
|||
ManualButtonClick = true
|
||||
};
|
||||
|
||||
colorButton.Click += (sender, e) => SetCurrentColor(colorButton.Color, true);
|
||||
colorButton.MouseClick += (sender, e) =>
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
SetCurrentColor(colorButton.Color, true);
|
||||
|
||||
if (!IsScreenColorPickerMode)
|
||||
{
|
||||
if (!previousColor.IsEmpty && previousColor == colorButton.Color)
|
||||
{
|
||||
CloseOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
previousColor = colorButton.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
flpRecentColors.Controls.Add(colorButton);
|
||||
if ((i + 1) % 16 == 0) flpRecentColors.SetFlowBreak(colorButton, true);
|
||||
|
@ -210,6 +230,13 @@ private void DrawPreviewColors()
|
|||
}
|
||||
}
|
||||
|
||||
private void CloseOK()
|
||||
{
|
||||
AddRecentColor(NewColor);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
private void ColorPickerForm_Shown(object sender, EventArgs e)
|
||||
|
@ -225,9 +252,7 @@ private void colorPicker_ColorChanged(object sender, ColorEventArgs e)
|
|||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddRecentColor(NewColor);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
CloseOK();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in a new issue