mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Remember color picker color palette mode selection
This commit is contained in:
parent
bc336f5b72
commit
eb2d90c0c9
11 changed files with 72 additions and 11 deletions
32
ShareX.HelpersLib/ColorPickerOptions.cs
Normal file
32
ShareX.HelpersLib/ColorPickerOptions.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
namespace ShareX.HelpersLib
|
||||||
|
{
|
||||||
|
public class ColorPickerOptions
|
||||||
|
{
|
||||||
|
public bool RecentColorsSelected { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,6 +66,8 @@ public Color Color
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
public bool ManualButtonClick { get; set; }
|
public bool ManualButtonClick { get; set; }
|
||||||
|
|
||||||
|
public ColorPickerOptions ColorPickerOptions { get; set; }
|
||||||
|
|
||||||
private bool isMouseHover;
|
private bool isMouseHover;
|
||||||
|
|
||||||
protected void OnColorChanged(Color color)
|
protected void OnColorChanged(Color color)
|
||||||
|
@ -85,7 +87,7 @@ protected override void OnMouseClick(MouseEventArgs mevent)
|
||||||
|
|
||||||
public void ShowColorDialog()
|
public void ShowColorDialog()
|
||||||
{
|
{
|
||||||
if (ColorPickerForm.PickColor(Color, out Color newColor, FindForm()))
|
if (ColorPickerForm.PickColor(Color, out Color newColor, FindForm(), null, ColorPickerOptions))
|
||||||
{
|
{
|
||||||
Color = newColor;
|
Color = newColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,34 @@ public partial class ColorPickerForm : Form
|
||||||
public MyColor NewColor { get; private set; }
|
public MyColor NewColor { get; private set; }
|
||||||
public MyColor OldColor { get; private set; }
|
public MyColor OldColor { get; private set; }
|
||||||
public bool IsScreenColorPickerMode { get; private set; }
|
public bool IsScreenColorPickerMode { get; private set; }
|
||||||
|
public ColorPickerOptions Options { get; private set; }
|
||||||
|
|
||||||
private bool oldColorExist;
|
private bool oldColorExist;
|
||||||
private bool controlChangingColor;
|
private bool controlChangingColor;
|
||||||
private ControlHider clipboardStatusHider;
|
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();
|
InitializeComponent();
|
||||||
ShareXResources.ApplyTheme(this);
|
ShareXResources.ApplyTheme(this);
|
||||||
clipboardStatusHider = new ControlHider(btnClipboardStatus, 2000);
|
clipboardStatusHider = new ControlHider(btnClipboardStatus, 2000);
|
||||||
|
|
||||||
IsScreenColorPickerMode = isScreenColorPickerMode;
|
IsScreenColorPickerMode = isScreenColorPickerMode;
|
||||||
|
Options = options;
|
||||||
|
|
||||||
|
if (Options == null)
|
||||||
|
{
|
||||||
|
Options = new ColorPickerOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Options.RecentColorsSelected)
|
||||||
|
{
|
||||||
|
rbRecentColors.Checked = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rbStandardColors.Checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
PrepareColorPalette();
|
PrepareColorPalette();
|
||||||
SetCurrentColor(currentColor, !IsScreenColorPickerMode);
|
SetCurrentColor(currentColor, !IsScreenColorPickerMode);
|
||||||
|
@ -90,9 +106,9 @@ public bool CheckClipboard()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool PickColor(Color currentColor, out Color newColor, Form owner = null, Func<PointInfo> openScreenColorPicker = null)
|
public static bool PickColor(Color currentColor, out Color newColor, Form owner = null, Func<PointInfo> openScreenColorPicker = null, ColorPickerOptions options = null)
|
||||||
{
|
{
|
||||||
using (ColorPickerForm dialog = new ColorPickerForm(currentColor))
|
using (ColorPickerForm dialog = new ColorPickerForm(currentColor, options: options))
|
||||||
{
|
{
|
||||||
if (openScreenColorPicker != null)
|
if (openScreenColorPicker != null)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +132,7 @@ private void PrepareColorPalette()
|
||||||
|
|
||||||
Color[] colors;
|
Color[] colors;
|
||||||
|
|
||||||
if (rbRecentColors.Checked)
|
if (Options.RecentColorsSelected)
|
||||||
{
|
{
|
||||||
colors = HelpersOptions.RecentColors.ToArray();
|
colors = HelpersOptions.RecentColors.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -296,6 +312,8 @@ private void colorPicker_ColorChanged(object sender, ColorEventArgs e)
|
||||||
|
|
||||||
private void rbRecentColors_CheckedChanged(object sender, EventArgs e)
|
private void rbRecentColors_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Options.RecentColorsSelected = rbRecentColors.Checked;
|
||||||
|
|
||||||
PrepareColorPalette();
|
PrepareColorPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
<Compile Include="..\SharedAssemblyInfo.cs">
|
<Compile Include="..\SharedAssemblyInfo.cs">
|
||||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="ColorPickerOptions.cs" />
|
||||||
<Compile Include="ControlHider.cs" />
|
<Compile Include="ControlHider.cs" />
|
||||||
<Compile Include="Controls\ObjectListView.cs">
|
<Compile Include="Controls\ObjectListView.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
|
|
|
@ -47,6 +47,7 @@ public NewImageForm(RegionCaptureOptions options)
|
||||||
nudWidth.Value = Options.EditorNewImageSize.Width;
|
nudWidth.Value = Options.EditorNewImageSize.Width;
|
||||||
nudHeight.Value = Options.EditorNewImageSize.Height;
|
nudHeight.Value = Options.EditorNewImageSize.Height;
|
||||||
cbTransparent.Checked = Options.EditorNewImageTransparent;
|
cbTransparent.Checked = Options.EditorNewImageTransparent;
|
||||||
|
btnChangeColor.ColorPickerOptions = options.ColorPickerOptions;
|
||||||
btnChangeColor.Color = options.EditorNewImageBackgroundColor;
|
btnChangeColor.Color = options.EditorNewImageBackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,16 +37,18 @@ internal partial class TextDrawingInputBox : Form
|
||||||
{
|
{
|
||||||
public string InputText { get; private set; }
|
public string InputText { get; private set; }
|
||||||
public TextDrawingOptions Options { get; private set; }
|
public TextDrawingOptions Options { get; private set; }
|
||||||
|
public ColorPickerOptions ColorPickerOptions { get; private set; }
|
||||||
|
|
||||||
private int processKeyCount;
|
private int processKeyCount;
|
||||||
|
|
||||||
public TextDrawingInputBox(string text, TextDrawingOptions options, bool supportGradient)
|
public TextDrawingInputBox(string text, TextDrawingOptions options, bool supportGradient, ColorPickerOptions colorPickerOptions)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ShareXResources.ApplyTheme(this);
|
ShareXResources.ApplyTheme(this);
|
||||||
|
|
||||||
InputText = text;
|
InputText = text;
|
||||||
Options = options;
|
Options = options;
|
||||||
|
ColorPickerOptions = colorPickerOptions;
|
||||||
|
|
||||||
if (InputText != null)
|
if (InputText != null)
|
||||||
{
|
{
|
||||||
|
@ -67,6 +69,8 @@ public TextDrawingInputBox(string text, TextDrawingOptions options, bool support
|
||||||
}
|
}
|
||||||
|
|
||||||
nudTextSize.SetValue(Options.Size);
|
nudTextSize.SetValue(Options.Size);
|
||||||
|
|
||||||
|
btnTextColor.ColorPickerOptions = ColorPickerOptions;
|
||||||
btnTextColor.Color = Options.Color;
|
btnTextColor.Color = Options.Color;
|
||||||
|
|
||||||
btnGradient.Visible = supportGradient;
|
btnGradient.Visible = supportGradient;
|
||||||
|
@ -163,7 +167,7 @@ private void tsmiEnableGradient_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
private void tsmiSecondColor_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;
|
Options.Color2 = newColor;
|
||||||
if (tsmiSecondColor.Image != null) tsmiSecondColor.Image.Dispose();
|
if (tsmiSecondColor.Image != null) tsmiSecondColor.Image.Dispose();
|
||||||
tsmiSecondColor.Image = ImageHelpers.CreateColorPickerIcon(Options.Color2, new Rectangle(0, 0, 16, 16));
|
tsmiSecondColor.Image = ImageHelpers.CreateColorPickerIcon(Options.Color2, new Rectangle(0, 0, 16, 16));
|
||||||
|
|
|
@ -100,6 +100,9 @@ public class RegionCaptureOptions
|
||||||
public List<ImageEffectPreset> ImageEffectPresets = new List<ImageEffectPreset>();
|
public List<ImageEffectPreset> ImageEffectPresets = new List<ImageEffectPreset>();
|
||||||
public int SelectedImageEffectPreset = 0;
|
public int SelectedImageEffectPreset = 0;
|
||||||
|
|
||||||
|
// Color picker
|
||||||
|
public ColorPickerOptions ColorPickerOptions = new ColorPickerOptions();
|
||||||
|
|
||||||
// Screen color picker
|
// Screen color picker
|
||||||
public string ScreenColorPickerInfoText = "";
|
public string ScreenColorPickerInfoText = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ public static SimpleWindowInfo GetWindowInfo(RegionCaptureOptions options)
|
||||||
public static void ShowScreenColorPickerDialog(RegionCaptureOptions options)
|
public static void ShowScreenColorPickerDialog(RegionCaptureOptions options)
|
||||||
{
|
{
|
||||||
Color color = Color.Red;
|
Color color = Color.Red;
|
||||||
ColorPickerForm colorPickerForm = new ColorPickerForm(color, true);
|
ColorPickerForm colorPickerForm = new ColorPickerForm(color, true, true, options.ColorPickerOptions);
|
||||||
colorPickerForm.EnableScreenColorPickerButton(() => GetPointInfo(options));
|
colorPickerForm.EnableScreenColorPickerButton(() => GetPointInfo(options));
|
||||||
colorPickerForm.Show();
|
colorPickerForm.Show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ private bool ShowTextInputBox()
|
||||||
|
|
||||||
Manager.Form.Pause();
|
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;
|
result = inputBox.ShowDialog(Manager.Form) == DialogResult.OK;
|
||||||
Text = inputBox.InputText;
|
Text = inputBox.InputText;
|
||||||
|
|
|
@ -2098,7 +2098,7 @@ private bool PickColor(Color currentColor, out Color newColor)
|
||||||
openScreenColorPicker = () => RegionCaptureTasks.GetPointInfo(Options);
|
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)
|
private void OnCurrentShapeChanged(BaseShape shape)
|
||||||
|
|
|
@ -690,7 +690,7 @@ public static void ShowScreenColorPickerDialog(TaskSettings taskSettings = null)
|
||||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||||
taskSettings.CaptureSettings.SurfaceOptions.ScreenColorPickerInfoText = taskSettings.ToolsSettings.ScreenColorPickerInfoText;
|
taskSettings.CaptureSettings.SurfaceOptions.ScreenColorPickerInfoText = taskSettings.ToolsSettings.ScreenColorPickerInfoText;
|
||||||
|
|
||||||
RegionCaptureTasks.ShowScreenColorPickerDialog(taskSettings.CaptureSettings.SurfaceOptions);
|
RegionCaptureTasks.ShowScreenColorPickerDialog(taskSettings.CaptureSettingsReference.SurfaceOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OpenScreenColorPicker(TaskSettings taskSettings = null)
|
public static void OpenScreenColorPicker(TaskSettings taskSettings = null)
|
||||||
|
|
Loading…
Reference in a new issue