mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Use PickColor static method and show old color by default
This commit is contained in:
parent
ca4e4ce09e
commit
15e63e8a92
5 changed files with 58 additions and 66 deletions
|
@ -37,19 +37,19 @@ public partial class ColorPickerForm : Form
|
|||
private bool oldColorExist;
|
||||
private bool controlChangingColor;
|
||||
|
||||
public ColorPickerForm() : this(Color.Red)
|
||||
public ColorPickerForm() : this(Color.Red, false)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorPickerForm(Color currentColor)
|
||||
public ColorPickerForm(Color currentColor, bool showOldColor = true)
|
||||
{
|
||||
InitializeComponent();
|
||||
Icon = ShareXResources.Icon;
|
||||
|
||||
SetCurrentColor(currentColor, false);
|
||||
SetCurrentColor(currentColor, showOldColor);
|
||||
}
|
||||
|
||||
public static Color GetColor(Color currentColor)
|
||||
public static bool PickColor(Color currentColor, out Color newColor)
|
||||
{
|
||||
using (ColorPickerForm dialog = new ColorPickerForm(currentColor))
|
||||
{
|
||||
|
@ -57,11 +57,13 @@ public static Color GetColor(Color currentColor)
|
|||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
return dialog.NewColor;
|
||||
newColor = dialog.NewColor;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return currentColor;
|
||||
newColor = currentColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetCurrentColor(Color currentColor, bool keepPreviousColor)
|
||||
|
|
|
@ -74,12 +74,9 @@ protected override void OnMouseClick(MouseEventArgs mevent)
|
|||
|
||||
public void ShowColorDialog()
|
||||
{
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(Color))
|
||||
if (ColorPickerForm.PickColor(Color, out Color newColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Color = dialogColor.NewColor;
|
||||
}
|
||||
Color = newColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -225,16 +225,14 @@ private void rbRedGreenBlue_CheckedChanged(object sender, EventArgs e)
|
|||
|
||||
private void btnColorDialog_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(Color.FromArgb(tbRed.Value, tbGreen.Value, tbBlue.Value)))
|
||||
Color currentColor = Color.FromArgb(tbRed.Value, tbGreen.Value, tbBlue.Value);
|
||||
|
||||
if (ColorPickerForm.PickColor(currentColor, out Color newColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Color color = dialogColor.NewColor;
|
||||
tbRed.Value = color.R;
|
||||
tbGreen.Value = color.G;
|
||||
tbBlue.Value = color.B;
|
||||
DrawRedGreenBlue();
|
||||
}
|
||||
tbRed.Value = newColor.R;
|
||||
tbGreen.Value = newColor.G;
|
||||
tbBlue.Value = newColor.B;
|
||||
DrawRedGreenBlue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,11 @@ private void RectangleAnnotate_KeyDown(object sender, KeyEventArgs e)
|
|||
try
|
||||
{
|
||||
isBusy = true;
|
||||
Options.DrawingPenColor = ColorPickerForm.GetColor(Options.DrawingPenColor);
|
||||
|
||||
if (ColorPickerForm.PickColor(Options.DrawingPenColor, out Color newColor))
|
||||
{
|
||||
Options.DrawingPenColor = newColor;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -325,30 +325,27 @@ private void CreateToolbar()
|
|||
borderColor = AnnotationOptions.BorderColor;
|
||||
}
|
||||
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(borderColor))
|
||||
if (ColorPickerForm.PickColor(borderColor, out Color newColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
|
||||
{
|
||||
if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
|
||||
{
|
||||
AnnotationOptions.TextBorderColor = dialogColor.NewColor;
|
||||
}
|
||||
else if (shapeType == ShapeType.DrawingTextOutline)
|
||||
{
|
||||
AnnotationOptions.TextOutlineBorderColor = dialogColor.NewColor;
|
||||
}
|
||||
else if (shapeType == ShapeType.DrawingStep)
|
||||
{
|
||||
AnnotationOptions.StepBorderColor = dialogColor.NewColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnnotationOptions.BorderColor = dialogColor.NewColor;
|
||||
}
|
||||
|
||||
UpdateMenu();
|
||||
UpdateCurrentShape();
|
||||
AnnotationOptions.TextBorderColor = newColor;
|
||||
}
|
||||
else if (shapeType == ShapeType.DrawingTextOutline)
|
||||
{
|
||||
AnnotationOptions.TextOutlineBorderColor = newColor;
|
||||
}
|
||||
else if (shapeType == ShapeType.DrawingStep)
|
||||
{
|
||||
AnnotationOptions.StepBorderColor = newColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnnotationOptions.BorderColor = newColor;
|
||||
}
|
||||
|
||||
UpdateMenu();
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
|
||||
ResumeForm();
|
||||
|
@ -378,26 +375,23 @@ private void CreateToolbar()
|
|||
fillColor = AnnotationOptions.FillColor;
|
||||
}
|
||||
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(fillColor))
|
||||
if (ColorPickerForm.PickColor(fillColor, out Color newColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
|
||||
{
|
||||
if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
|
||||
{
|
||||
AnnotationOptions.TextFillColor = dialogColor.NewColor;
|
||||
}
|
||||
else if (shapeType == ShapeType.DrawingStep)
|
||||
{
|
||||
AnnotationOptions.StepFillColor = dialogColor.NewColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnnotationOptions.FillColor = dialogColor.NewColor;
|
||||
}
|
||||
|
||||
UpdateMenu();
|
||||
UpdateCurrentShape();
|
||||
AnnotationOptions.TextFillColor = newColor;
|
||||
}
|
||||
else if (shapeType == ShapeType.DrawingStep)
|
||||
{
|
||||
AnnotationOptions.StepFillColor = newColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnnotationOptions.FillColor = newColor;
|
||||
}
|
||||
|
||||
UpdateMenu();
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
|
||||
ResumeForm();
|
||||
|
@ -410,14 +404,11 @@ private void CreateToolbar()
|
|||
{
|
||||
PauseForm();
|
||||
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.HighlightColor))
|
||||
if (ColorPickerForm.PickColor(AnnotationOptions.HighlightColor, out Color newColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
AnnotationOptions.HighlightColor = dialogColor.NewColor;
|
||||
UpdateMenu();
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
AnnotationOptions.HighlightColor = newColor;
|
||||
UpdateMenu();
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
|
||||
ResumeForm();
|
||||
|
|
Loading…
Reference in a new issue