2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2017-01-11 21:39:40 +13:00
|
|
|
|
Copyright (c) 2007-2017 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.HelpersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
[DefaultEvent("ColorChanged")]
|
|
|
|
|
public class ColorPicker : UserControl
|
|
|
|
|
{
|
|
|
|
|
public event ColorEventHandler ColorChanged;
|
|
|
|
|
|
|
|
|
|
private MyColor selectedColor;
|
|
|
|
|
|
|
|
|
|
public MyColor SelectedColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return selectedColor;
|
|
|
|
|
}
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
if (selectedColor != value)
|
|
|
|
|
{
|
|
|
|
|
selectedColor = value;
|
|
|
|
|
colorBox.SelectedColor = selectedColor;
|
|
|
|
|
colorSlider.SelectedColor = selectedColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DrawStyle drawStyle;
|
|
|
|
|
|
|
|
|
|
public DrawStyle DrawStyle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return drawStyle;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (drawStyle != value)
|
|
|
|
|
{
|
|
|
|
|
drawStyle = value;
|
|
|
|
|
colorBox.DrawStyle = value;
|
|
|
|
|
colorSlider.DrawStyle = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 02:01:12 +13:00
|
|
|
|
public bool CrosshairVisible
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-01 02:01:12 +13:00
|
|
|
|
colorBox.CrosshairVisible = value;
|
|
|
|
|
colorSlider.CrosshairVisible = value;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ColorBox colorBox;
|
|
|
|
|
private ColorSlider colorSlider;
|
|
|
|
|
|
|
|
|
|
public ColorPicker()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
DrawStyle = DrawStyle.Hue;
|
|
|
|
|
colorBox.ColorChanged += colorBox_ColorChanged;
|
|
|
|
|
colorSlider.ColorChanged += colorSlider_ColorChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void colorBox_ColorChanged(object sender, ColorEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectedColor = e.Color;
|
|
|
|
|
colorSlider.SelectedColor = SelectedColor;
|
|
|
|
|
OnColorChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void colorSlider_ColorChanged(object sender, ColorEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectedColor = e.Color;
|
|
|
|
|
colorBox.SelectedColor = SelectedColor;
|
|
|
|
|
OnColorChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ChangeColor(Color color, ColorType colorType = ColorType.None)
|
|
|
|
|
{
|
|
|
|
|
SelectedColor = color;
|
|
|
|
|
OnColorChanged(colorType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnColorChanged(ColorType colorType = ColorType.None)
|
|
|
|
|
{
|
|
|
|
|
if (ColorChanged != null)
|
|
|
|
|
{
|
|
|
|
|
ColorChanged(this, new ColorEventArgs(SelectedColor, colorType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Component Designer generated code
|
|
|
|
|
|
|
|
|
|
private System.ComponentModel.IContainer components = null;
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (disposing && (components != null))
|
|
|
|
|
{
|
|
|
|
|
components.Dispose();
|
|
|
|
|
}
|
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
|
|
|
|
this.colorBox = new HelpersLib.ColorBox();
|
|
|
|
|
this.colorSlider = new HelpersLib.ColorSlider();
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.SuspendLayout();
|
2014-03-29 01:55:41 +13:00
|
|
|
|
//
|
2013-11-03 23:53:49 +13:00
|
|
|
|
// colorBox
|
2014-03-29 01:55:41 +13:00
|
|
|
|
//
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.colorBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.colorBox.DrawStyle = HelpersLib.DrawStyle.Hue;
|
|
|
|
|
this.colorBox.Location = new System.Drawing.Point(0, 0);
|
|
|
|
|
this.colorBox.Name = "colorBox";
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.colorBox.Size = new System.Drawing.Size(258, 258);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.colorBox.TabIndex = 0;
|
2014-03-29 01:55:41 +13:00
|
|
|
|
//
|
2013-11-03 23:53:49 +13:00
|
|
|
|
// colorSlider
|
2014-03-29 01:55:41 +13:00
|
|
|
|
//
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.colorSlider.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.colorSlider.DrawStyle = HelpersLib.DrawStyle.Hue;
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.colorSlider.Location = new System.Drawing.Point(257, 0);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.colorSlider.Name = "colorSlider";
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.colorSlider.Size = new System.Drawing.Size(32, 258);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.colorSlider.TabIndex = 1;
|
2014-03-29 01:55:41 +13:00
|
|
|
|
//
|
2013-11-03 23:53:49 +13:00
|
|
|
|
// ColorPicker
|
2014-03-29 01:55:41 +13:00
|
|
|
|
//
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.AutoSize = true;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.Controls.Add(this.colorBox);
|
|
|
|
|
this.Controls.Add(this.colorSlider);
|
|
|
|
|
this.Name = "ColorPicker";
|
2013-11-04 07:48:46 +13:00
|
|
|
|
this.Size = new System.Drawing.Size(292, 261);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
this.ResumeLayout(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Component Designer generated code
|
|
|
|
|
}
|
|
|
|
|
}
|