Color picker form now by default checks clipboard for color text
This commit is contained in:
parent
be0cc6c97f
commit
a883f2bf63
@ -41,7 +41,7 @@ namespace ShareX.HelpersLib
|
||||
private bool oldColorExist;
|
||||
private bool controlChangingColor;
|
||||
|
||||
public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false)
|
||||
public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false, bool checkClipboard = true)
|
||||
{
|
||||
InitializeComponent();
|
||||
ShareXResources.ApplyTheme(this);
|
||||
@ -51,6 +51,11 @@ namespace ShareX.HelpersLib
|
||||
PrepareColorPalette();
|
||||
SetCurrentColor(currentColor, !IsScreenColorPickerMode);
|
||||
|
||||
if (checkClipboard)
|
||||
{
|
||||
CheckClipboard();
|
||||
}
|
||||
|
||||
btnOK.Visible = btnCancel.Visible = !IsScreenColorPickerMode;
|
||||
mbCopy.Visible = btnClose.Visible = pCursorPosition.Visible = IsScreenColorPickerMode;
|
||||
}
|
||||
@ -61,6 +66,19 @@ namespace ShareX.HelpersLib
|
||||
btnScreenColorPicker.Visible = true;
|
||||
}
|
||||
|
||||
public bool CheckClipboard()
|
||||
{
|
||||
string text = ClipboardHelpers.GetText(true);
|
||||
|
||||
if (!string.IsNullOrEmpty(text) && ColorHelpers.ParseColor(text, out Color clipboardColor))
|
||||
{
|
||||
colorPicker.ChangeColor(clipboardColor);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool PickColor(Color currentColor, out Color newColor, Form owner = null, Func<PointInfo> openScreenColorPicker = null)
|
||||
{
|
||||
using (ColorPickerForm dialog = new ColorPickerForm(currentColor))
|
||||
|
@ -143,20 +143,9 @@ namespace ShareX.ScreenCaptureLib
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ShowScreenColorPickerDialog(RegionCaptureOptions options, bool checkClipboard = true)
|
||||
public static void ShowScreenColorPickerDialog(RegionCaptureOptions options)
|
||||
{
|
||||
Color color = Color.Red;
|
||||
|
||||
if (checkClipboard)
|
||||
{
|
||||
string text = ClipboardHelpers.GetText(true);
|
||||
|
||||
if (!string.IsNullOrEmpty(text) && ColorHelpers.ParseColor(text, out Color clipboardColor))
|
||||
{
|
||||
color = clipboardColor;
|
||||
}
|
||||
}
|
||||
|
||||
ColorPickerForm colorPickerForm = new ColorPickerForm(color, true);
|
||||
colorPickerForm.EnableScreenColorPickerButton(() => GetPointInfo(options));
|
||||
colorPickerForm.Show();
|
||||
|
@ -792,7 +792,7 @@ namespace ShareX
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
RegionCaptureTasks.ShowScreenColorPickerDialog(taskSettings.CaptureSettings.SurfaceOptions, true);
|
||||
RegionCaptureTasks.ShowScreenColorPickerDialog(taskSettings.CaptureSettings.SurfaceOptions);
|
||||
}
|
||||
|
||||
public static void OpenScreenColorPicker(TaskSettings taskSettings = null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user