diff --git a/ShareX.HelpersLib/ColorPickerOptions.cs b/ShareX.HelpersLib/ColorPickerOptions.cs
new file mode 100644
index 000000000..f0ee30068
--- /dev/null
+++ b/ShareX.HelpersLib/ColorPickerOptions.cs
@@ -0,0 +1,32 @@
+#region License Information (GPL v3)
+
+/*
+ ShareX - A program that allows you to take screenshots and share any file type
+ Copyright (c) 2007-2021 ShareX Team
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Optionally you can also view the license at .
+*/
+
+#endregion License Information (GPL v3)
+
+namespace ShareX.HelpersLib
+{
+ public class ColorPickerOptions
+ {
+ public bool RecentColorsSelected { get; set; } = true;
+ }
+}
\ No newline at end of file
diff --git a/ShareX.HelpersLib/Controls/ColorButton.cs b/ShareX.HelpersLib/Controls/ColorButton.cs
index d5b8ac591..ad9a25d83 100644
--- a/ShareX.HelpersLib/Controls/ColorButton.cs
+++ b/ShareX.HelpersLib/Controls/ColorButton.cs
@@ -66,6 +66,8 @@ public Color Color
[DefaultValue(false)]
public bool ManualButtonClick { get; set; }
+ public ColorPickerOptions ColorPickerOptions { get; set; }
+
private bool isMouseHover;
protected void OnColorChanged(Color color)
@@ -85,7 +87,7 @@ protected override void OnMouseClick(MouseEventArgs mevent)
public void ShowColorDialog()
{
- if (ColorPickerForm.PickColor(Color, out Color newColor, FindForm()))
+ if (ColorPickerForm.PickColor(Color, out Color newColor, FindForm(), null, ColorPickerOptions))
{
Color = newColor;
}
diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.cs b/ShareX.HelpersLib/Forms/ColorPickerForm.cs
index c6c3ca491..ad8cc86dc 100644
--- a/ShareX.HelpersLib/Forms/ColorPickerForm.cs
+++ b/ShareX.HelpersLib/Forms/ColorPickerForm.cs
@@ -37,18 +37,34 @@ public partial class ColorPickerForm : Form
public MyColor NewColor { get; private set; }
public MyColor OldColor { get; private set; }
public bool IsScreenColorPickerMode { get; private set; }
+ public ColorPickerOptions Options { get; private set; }
private bool oldColorExist;
private bool controlChangingColor;
private ControlHider clipboardStatusHider;
- public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false, bool checkClipboard = true)
+ public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false, bool checkClipboard = true, ColorPickerOptions options = null)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
clipboardStatusHider = new ControlHider(btnClipboardStatus, 2000);
IsScreenColorPickerMode = isScreenColorPickerMode;
+ Options = options;
+
+ if (Options == null)
+ {
+ Options = new ColorPickerOptions();
+ }
+
+ if (Options.RecentColorsSelected)
+ {
+ rbRecentColors.Checked = true;
+ }
+ else
+ {
+ rbStandardColors.Checked = true;
+ }
PrepareColorPalette();
SetCurrentColor(currentColor, !IsScreenColorPickerMode);
@@ -90,9 +106,9 @@ public bool CheckClipboard()
return false;
}
- public static bool PickColor(Color currentColor, out Color newColor, Form owner = null, Func openScreenColorPicker = null)
+ public static bool PickColor(Color currentColor, out Color newColor, Form owner = null, Func openScreenColorPicker = null, ColorPickerOptions options = null)
{
- using (ColorPickerForm dialog = new ColorPickerForm(currentColor))
+ using (ColorPickerForm dialog = new ColorPickerForm(currentColor, options: options))
{
if (openScreenColorPicker != null)
{
@@ -116,7 +132,7 @@ private void PrepareColorPalette()
Color[] colors;
- if (rbRecentColors.Checked)
+ if (Options.RecentColorsSelected)
{
colors = HelpersOptions.RecentColors.ToArray();
}
@@ -296,6 +312,8 @@ private void colorPicker_ColorChanged(object sender, ColorEventArgs e)
private void rbRecentColors_CheckedChanged(object sender, EventArgs e)
{
+ Options.RecentColorsSelected = rbRecentColors.Checked;
+
PrepareColorPalette();
}
diff --git a/ShareX.HelpersLib/ShareX.HelpersLib.csproj b/ShareX.HelpersLib/ShareX.HelpersLib.csproj
index 0ac735029..36a0c0d4b 100644
--- a/ShareX.HelpersLib/ShareX.HelpersLib.csproj
+++ b/ShareX.HelpersLib/ShareX.HelpersLib.csproj
@@ -104,6 +104,7 @@
Properties\SharedAssemblyInfo.cs
+
Component
diff --git a/ShareX.ScreenCaptureLib/Forms/NewImageForm.cs b/ShareX.ScreenCaptureLib/Forms/NewImageForm.cs
index a4706d377..509ff7275 100644
--- a/ShareX.ScreenCaptureLib/Forms/NewImageForm.cs
+++ b/ShareX.ScreenCaptureLib/Forms/NewImageForm.cs
@@ -47,6 +47,7 @@ public NewImageForm(RegionCaptureOptions options)
nudWidth.Value = Options.EditorNewImageSize.Width;
nudHeight.Value = Options.EditorNewImageSize.Height;
cbTransparent.Checked = Options.EditorNewImageTransparent;
+ btnChangeColor.ColorPickerOptions = options.ColorPickerOptions;
btnChangeColor.Color = options.EditorNewImageBackgroundColor;
}
diff --git a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs
index 11308e691..8cc278839 100644
--- a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs
+++ b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs
@@ -37,16 +37,18 @@ internal partial class TextDrawingInputBox : Form
{
public string InputText { get; private set; }
public TextDrawingOptions Options { get; private set; }
+ public ColorPickerOptions ColorPickerOptions { get; private set; }
private int processKeyCount;
- public TextDrawingInputBox(string text, TextDrawingOptions options, bool supportGradient)
+ public TextDrawingInputBox(string text, TextDrawingOptions options, bool supportGradient, ColorPickerOptions colorPickerOptions)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
InputText = text;
Options = options;
+ ColorPickerOptions = colorPickerOptions;
if (InputText != null)
{
@@ -67,6 +69,8 @@ public TextDrawingInputBox(string text, TextDrawingOptions options, bool support
}
nudTextSize.SetValue(Options.Size);
+
+ btnTextColor.ColorPickerOptions = ColorPickerOptions;
btnTextColor.Color = Options.Color;
btnGradient.Visible = supportGradient;
@@ -163,7 +167,7 @@ private void tsmiEnableGradient_Click(object sender, EventArgs e)
private void tsmiSecondColor_Click(object sender, EventArgs e)
{
- ColorPickerForm.PickColor(Options.Color2, out Color newColor, this);
+ ColorPickerForm.PickColor(Options.Color2, out Color newColor, this, null, ColorPickerOptions);
Options.Color2 = newColor;
if (tsmiSecondColor.Image != null) tsmiSecondColor.Image.Dispose();
tsmiSecondColor.Image = ImageHelpers.CreateColorPickerIcon(Options.Color2, new Rectangle(0, 0, 16, 16));
diff --git a/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs b/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs
index fd003abdd..20cf0b776 100644
--- a/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs
+++ b/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs
@@ -100,6 +100,9 @@ public class RegionCaptureOptions
public List ImageEffectPresets = new List();
public int SelectedImageEffectPreset = 0;
+ // Color picker
+ public ColorPickerOptions ColorPickerOptions = new ColorPickerOptions();
+
// Screen color picker
public string ScreenColorPickerInfoText = "";
}
diff --git a/ShareX.ScreenCaptureLib/RegionCaptureTasks.cs b/ShareX.ScreenCaptureLib/RegionCaptureTasks.cs
index cdf92f2b2..619d23b29 100644
--- a/ShareX.ScreenCaptureLib/RegionCaptureTasks.cs
+++ b/ShareX.ScreenCaptureLib/RegionCaptureTasks.cs
@@ -146,7 +146,7 @@ public static SimpleWindowInfo GetWindowInfo(RegionCaptureOptions options)
public static void ShowScreenColorPickerDialog(RegionCaptureOptions options)
{
Color color = Color.Red;
- ColorPickerForm colorPickerForm = new ColorPickerForm(color, true);
+ ColorPickerForm colorPickerForm = new ColorPickerForm(color, true, true, options.ColorPickerOptions);
colorPickerForm.EnableScreenColorPickerButton(() => GetPointInfo(options));
colorPickerForm.Show();
}
diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs
index 719d0664f..d17d22e52 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs
@@ -131,7 +131,7 @@ private bool ShowTextInputBox()
Manager.Form.Pause();
- using (TextDrawingInputBox inputBox = new TextDrawingInputBox(Text, TextOptions, SupportGradient))
+ using (TextDrawingInputBox inputBox = new TextDrawingInputBox(Text, TextOptions, SupportGradient, Manager.Options.ColorPickerOptions))
{
result = inputBox.ShowDialog(Manager.Form) == DialogResult.OK;
Text = inputBox.InputText;
diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs
index 9e1bac028..f1d7039ce 100644
--- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs
@@ -2098,7 +2098,7 @@ private bool PickColor(Color currentColor, out Color newColor)
openScreenColorPicker = () => RegionCaptureTasks.GetPointInfo(Options);
}
- return ColorPickerForm.PickColor(currentColor, out newColor, Form, openScreenColorPicker);
+ return ColorPickerForm.PickColor(currentColor, out newColor, Form, openScreenColorPicker, Options.ColorPickerOptions);
}
private void OnCurrentShapeChanged(BaseShape shape)
diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs
index d7ebfdd23..7238cdd5f 100644
--- a/ShareX/TaskHelpers.cs
+++ b/ShareX/TaskHelpers.cs
@@ -690,7 +690,7 @@ public static void ShowScreenColorPickerDialog(TaskSettings taskSettings = null)
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
taskSettings.CaptureSettings.SurfaceOptions.ScreenColorPickerInfoText = taskSettings.ToolsSettings.ScreenColorPickerInfoText;
- RegionCaptureTasks.ShowScreenColorPickerDialog(taskSettings.CaptureSettings.SurfaceOptions);
+ RegionCaptureTasks.ShowScreenColorPickerDialog(taskSettings.CaptureSettingsReference.SurfaceOptions);
}
public static void OpenScreenColorPicker(TaskSettings taskSettings = null)