In color picker don't copy fields on double click

This commit is contained in:
Jaex 2017-05-17 15:44:25 +03:00
parent 638aacf0b1
commit e428ad0ebf
2 changed files with 14 additions and 38 deletions

View file

@ -308,22 +308,25 @@ public static bool ParseColor(string text, out Color color)
{ {
text = text.Trim(); text = text.Trim();
Match matchHex = Regex.Match(text, @"^(?:#|0x)?((?:[0-9A-F]{2}){3})$", RegexOptions.IgnoreCase); if (text.Length <= 20)
if (matchHex.Success)
{ {
color = HexToColor(matchHex.Groups[1].Value); Match matchHex = Regex.Match(text, @"^(?:#|0x)?((?:[0-9A-F]{2}){3})$", RegexOptions.IgnoreCase);
return true;
}
else
{
Match matchRGB = Regex.Match(text, @"^(?:rgb\()?([1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])(?:\s|,)+([1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])(?:\s|,)+([1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\)?$");
if (matchRGB.Success) if (matchHex.Success)
{ {
color = Color.FromArgb(int.Parse(matchRGB.Groups[1].Value), int.Parse(matchRGB.Groups[2].Value), int.Parse(matchRGB.Groups[3].Value)); color = HexToColor(matchHex.Groups[1].Value);
return true; return true;
} }
else
{
Match matchRGB = Regex.Match(text, @"^(?:rgb\()?([1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])(?:\s|,)+([1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])(?:\s|,)+([1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\)?$");
if (matchRGB.Success)
{
color = Color.FromArgb(int.Parse(matchRGB.Groups[1].Value), int.Parse(matchRGB.Groups[2].Value), int.Parse(matchRGB.Groups[3].Value));
return true;
}
}
} }
} }

View file

@ -47,14 +47,6 @@ public ScreenColorPicker(bool checkClipboard = false)
UpdateControls(false); UpdateControls(false);
foreach (Control control in Controls)
{
if (control is NumericUpDown || control is TextBox)
{
control.DoubleClick += CopyToClipboard;
}
}
if (checkClipboard) if (checkClipboard)
{ {
if (Clipboard.ContainsText()) if (Clipboard.ContainsText())
@ -69,25 +61,6 @@ public ScreenColorPicker(bool checkClipboard = false)
} }
} }
private void CopyToClipboard(object sender, EventArgs e)
{
string text = "";
if (sender is NumericUpDown)
{
text = ((NumericUpDown)sender).Value.ToString();
}
else if (sender is TextBox)
{
text = ((TextBox)sender).Text;
}
if (!string.IsNullOrEmpty(text))
{
ClipboardHelpers.CopyText(text);
}
}
private void UpdateColor(int x, int y) private void UpdateColor(int x, int y)
{ {
UpdateColor(x, y, CaptureHelpers.GetPixelColor(x, y)); UpdateColor(x, y, CaptureHelpers.GetPixelColor(x, y));