Reworked the color picker

This commit is contained in:
2022-06-08 10:15:16 +02:00
parent 1a468895ad
commit 3a6c7531e0
7 changed files with 198 additions and 133 deletions

View File

@@ -64,9 +64,7 @@ namespace Paint_2
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
Size pointSize;
List<Point> points = new List<Point>();
foreach (List<Point> drawing in Drawings)
{
@@ -131,15 +129,10 @@ namespace Paint_2
Point p2_2 = Utils.Lerp(p2, p3, t);
Point p3_2 = Utils.Lerp(p3, p4, t);
//gr.DrawLine(new Pen(GetRandomColor(), Widths[0]), p1_2, p2_2);
//gr.DrawLine(new Pen(GetRandomColor(), Widths[0]), p2_2, p3_2);
//Drawing the second step of the curve
Point p1_3 = Utils.Lerp(p1_2, p2_2, t);
Point p2_3 = Utils.Lerp(p2_2, p3_2, t);
//gr.DrawLine(new Pen(GetRandomColor(), Widths[0]), p1_3, p2_3);
//Drawing the Bezier Point
Point p1_4 = Utils.Lerp(p1_3, p2_3, t);

View File

@@ -29,29 +29,31 @@
private void InitializeComponent()
{
this.pbxColor = new System.Windows.Forms.PictureBox();
this.tbrRedLevel = new System.Windows.Forms.TrackBar();
this.pbxSelectedColor = new System.Windows.Forms.PictureBox();
this.nupRed = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.lbl4 = new System.Windows.Forms.Label();
this.nupGreen = new System.Windows.Forms.NumericUpDown();
this.nupBlue = new System.Windows.Forms.NumericUpDown();
this.nupGamma = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label();
this.tbxColorHex = new System.Windows.Forms.TextBox();
this.pbxSliderRed = new System.Windows.Forms.PictureBox();
this.pbxSliderSaturation = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pbxColor)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tbrRedLevel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbxSelectedColor)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupRed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupGreen)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupBlue)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupGamma)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbxSliderRed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbxSliderSaturation)).BeginInit();
this.SuspendLayout();
//
// pbxColor
//
this.pbxColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxColor.Location = new System.Drawing.Point(13, 13);
this.pbxColor.Margin = new System.Windows.Forms.Padding(4);
this.pbxColor.Name = "pbxColor";
@@ -60,185 +62,188 @@
this.pbxColor.TabStop = false;
this.pbxColor.Click += new System.EventHandler(this.pbxColor_Click);
//
// tbrRedLevel
//
this.tbrRedLevel.Location = new System.Drawing.Point(13, 275);
this.tbrRedLevel.Maximum = 255;
this.tbrRedLevel.Name = "tbrRedLevel";
this.tbrRedLevel.Size = new System.Drawing.Size(255, 45);
this.tbrRedLevel.TabIndex = 3;
this.tbrRedLevel.TickStyle = System.Windows.Forms.TickStyle.None;
this.tbrRedLevel.Scroll += new System.EventHandler(this.tbrRedLevel_Scroll);
//
// pbxSelectedColor
//
this.pbxSelectedColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.pbxSelectedColor.Location = new System.Drawing.Point(13, 326);
this.pbxSelectedColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxSelectedColor.Location = new System.Drawing.Point(326, 205);
this.pbxSelectedColor.Name = "pbxSelectedColor";
this.pbxSelectedColor.Size = new System.Drawing.Size(255, 50);
this.pbxSelectedColor.Size = new System.Drawing.Size(100, 100);
this.pbxSelectedColor.TabIndex = 4;
this.pbxSelectedColor.TabStop = false;
//
// nupRed
//
this.nupRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.nupRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.nupRed.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupRed.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupRed.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupRed.Location = new System.Drawing.Point(14, 401);
this.nupRed.Location = new System.Drawing.Point(348, 12);
this.nupRed.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupRed.Name = "nupRed";
this.nupRed.Size = new System.Drawing.Size(60, 22);
this.nupRed.Size = new System.Drawing.Size(78, 27);
this.nupRed.TabIndex = 11;
this.nupRed.ValueChanged += new System.EventHandler(this.nupValueChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 380);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 18);
this.label1.TabIndex = 12;
this.label1.Text = "Red";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(77, 380);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 18);
this.label2.TabIndex = 13;
this.label2.Text = "Green";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(143, 380);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(40, 18);
this.label3.TabIndex = 14;
this.label3.Text = "Blue";
//
// lbl4
//
this.lbl4.AutoSize = true;
this.lbl4.Location = new System.Drawing.Point(207, 380);
this.lbl4.Name = "lbl4";
this.lbl4.Size = new System.Drawing.Size(48, 18);
this.lbl4.TabIndex = 15;
this.lbl4.Text = "Gamma";
//
// nupGreen
//
this.nupGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.nupGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.nupGreen.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupGreen.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupGreen.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupGreen.Location = new System.Drawing.Point(80, 401);
this.nupGreen.Location = new System.Drawing.Point(348, 46);
this.nupGreen.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupGreen.Name = "nupGreen";
this.nupGreen.Size = new System.Drawing.Size(60, 22);
this.nupGreen.Size = new System.Drawing.Size(78, 27);
this.nupGreen.TabIndex = 16;
this.nupGreen.ValueChanged += new System.EventHandler(this.nupValueChanged);
//
// nupBlue
//
this.nupBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.nupBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.nupBlue.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupBlue.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupBlue.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupBlue.Location = new System.Drawing.Point(146, 401);
this.nupBlue.Location = new System.Drawing.Point(348, 79);
this.nupBlue.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupBlue.Name = "nupBlue";
this.nupBlue.Size = new System.Drawing.Size(60, 22);
this.nupBlue.Size = new System.Drawing.Size(78, 27);
this.nupBlue.TabIndex = 17;
this.nupBlue.ValueChanged += new System.EventHandler(this.nupValueChanged);
//
// nupGamma
//
this.nupGamma.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.nupGamma.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.nupGamma.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupGamma.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupGamma.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupGamma.Location = new System.Drawing.Point(210, 401);
this.nupGamma.Location = new System.Drawing.Point(348, 112);
this.nupGamma.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupGamma.Name = "nupGamma";
this.nupGamma.Size = new System.Drawing.Size(60, 22);
this.nupGamma.Size = new System.Drawing.Size(78, 27);
this.nupGamma.TabIndex = 18;
this.nupGamma.ValueChanged += new System.EventHandler(this.nupValueChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(10, 426);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 18);
this.label4.TabIndex = 19;
this.label4.Text = "Hex";
//
// tbxColorHex
//
this.tbxColorHex.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.tbxColorHex.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.tbxColorHex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxColorHex.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.tbxColorHex.Location = new System.Drawing.Point(13, 447);
this.tbxColorHex.Location = new System.Drawing.Point(326, 155);
this.tbxColorHex.Name = "tbxColorHex";
this.tbxColorHex.Size = new System.Drawing.Size(257, 23);
this.tbxColorHex.Size = new System.Drawing.Size(100, 27);
this.tbxColorHex.TabIndex = 20;
this.tbxColorHex.TextChanged += new System.EventHandler(this.tbxColorHex_TextChanged);
this.tbxColorHex.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxColorHex_KeyDown);
//
// pbxSliderRed
//
this.pbxSliderRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxSliderRed.Location = new System.Drawing.Point(12, 275);
this.pbxSliderRed.Name = "pbxSliderRed";
this.pbxSliderRed.Size = new System.Drawing.Size(255, 30);
this.pbxSliderRed.TabIndex = 21;
this.pbxSliderRed.TabStop = false;
this.pbxSliderRed.Click += new System.EventHandler(this.pbxSliderRed_Click);
//
// pbxSliderSaturation
//
this.pbxSliderSaturation.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxSliderSaturation.Location = new System.Drawing.Point(275, 13);
this.pbxSliderSaturation.Name = "pbxSliderSaturation";
this.pbxSliderSaturation.Size = new System.Drawing.Size(30, 255);
this.pbxSliderSaturation.TabIndex = 22;
this.pbxSliderSaturation.TabStop = false;
this.pbxSliderSaturation.Click += new System.EventHandler(this.pbxSliderSaturation_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(322, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(20, 22);
this.label1.TabIndex = 23;
this.label1.Text = "R";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(322, 49);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 22);
this.label2.TabIndex = 24;
this.label2.Text = "G";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(322, 82);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(20, 22);
this.label3.TabIndex = 25;
this.label3.Text = "B";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(322, 115);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 22);
this.label4.TabIndex = 26;
this.label4.Text = "A";
//
// ColorPicker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 22F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.ClientSize = new System.Drawing.Size(280, 481);
this.Controls.Add(this.tbxColorHex);
this.ClientSize = new System.Drawing.Size(440, 316);
this.Controls.Add(this.label4);
this.Controls.Add(this.nupGamma);
this.Controls.Add(this.nupBlue);
this.Controls.Add(this.nupGreen);
this.Controls.Add(this.lbl4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.pbxSliderSaturation);
this.Controls.Add(this.pbxSliderRed);
this.Controls.Add(this.tbxColorHex);
this.Controls.Add(this.nupGamma);
this.Controls.Add(this.nupBlue);
this.Controls.Add(this.nupGreen);
this.Controls.Add(this.nupRed);
this.Controls.Add(this.pbxSelectedColor);
this.Controls.Add(this.tbrRedLevel);
this.Controls.Add(this.pbxColor);
this.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimumSize = new System.Drawing.Size(296, 520);
this.Name = "ColorPicker";
this.Text = "ColorPicker";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ColorPicker_FormClosing);
this.Load += new System.EventHandler(this.ColorPicker_Load);
this.Shown += new System.EventHandler(this.ColorPicker_Shown);
((System.ComponentModel.ISupportInitialize)(this.pbxColor)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tbrRedLevel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbxSelectedColor)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupRed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupGreen)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupBlue)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupGamma)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbxSliderRed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbxSliderSaturation)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -247,17 +252,17 @@
#endregion
private System.Windows.Forms.PictureBox pbxColor;
private System.Windows.Forms.TrackBar tbrRedLevel;
private System.Windows.Forms.PictureBox pbxSelectedColor;
private System.Windows.Forms.NumericUpDown nupRed;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label lbl4;
private System.Windows.Forms.NumericUpDown nupGreen;
private System.Windows.Forms.NumericUpDown nupBlue;
private System.Windows.Forms.NumericUpDown nupGamma;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox tbxColorHex;
private System.Windows.Forms.PictureBox pbxSliderRed;
private System.Windows.Forms.PictureBox pbxSliderSaturation;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
}
}

View File

@@ -12,10 +12,6 @@ namespace Paint_2
{
public partial class ColorPicker : Form
{
public Bitmap colorMap;
public int RedLevel = 0;
public int GreenLevel = 0;
public int BlueLevel = 0;
public Color SelectedColor;
public Point cursorLocation;
public PaintForm main;
@@ -27,52 +23,113 @@ namespace Paint_2
private void ColorPicker_Load(object sender, EventArgs e)
{
colorMap = new Bitmap(255, 255);
//SelectedColor = this.BackColor;
SelectedColor = main.sketch.CurrentTool.Color;
RedLevel = SelectedColor.R;
RefreshUi();
}
private Bitmap RefreshMap(Bitmap map)
private Bitmap RefreshMap(Size size)
{
Bitmap map = new Bitmap(size.Width, size.Height);
Graphics gr = Graphics.FromImage(map);
for (int g = 0; g < 255; g += 1)
for (int g = 0; g < size.Width; g += 1)
{
for (int b = 0; b < 255; b += 1)
for (int b = 0; b < size.Height; b += 1)
{
map.SetPixel(g, b, Color.FromArgb(255, RedLevel, g, b));
map.SetPixel(g, b, Color.FromArgb(SelectedColor.A, SelectedColor.R, g, b));
}
}
int cursorWidth = 15;
gr.DrawEllipse(new Pen(Color.Black, 2), new Rectangle(new Point(SelectedColor.G - cursorWidth / 2, SelectedColor.B - cursorWidth / 2), new Size(cursorWidth, cursorWidth)));
gr.FillEllipse(new SolidBrush(SelectedColor), new Rectangle(new Point(SelectedColor.G - cursorWidth / 2, SelectedColor.B - cursorWidth / 2), new Size(cursorWidth, cursorWidth)));
return map;
}
private Bitmap RefreshRedLevel(Size size, bool vertical)
{
Bitmap map = new Bitmap(size.Width, size.Height);
Graphics gr = Graphics.FromImage(map);
for (int x = 0; x < size.Width; x += 1)
{
for (int y = 0; y < size.Height; y += 1)
{
if (vertical)
{
map.SetPixel(x, y, Color.FromArgb(SelectedColor.A, y, SelectedColor.G, SelectedColor.B));
}
else
{
map.SetPixel(x, y, Color.FromArgb(SelectedColor.A, x, SelectedColor.G, SelectedColor.B));
}
}
}
return map;
}
private Bitmap RefreshGammaLevel(Size size, bool vertical)
{
Bitmap map = new Bitmap(size.Width,size.Height);
Graphics gr = Graphics.FromImage(map);
for (int x = 0; x < size.Width; x++)
{
for (int y = 0; y < size.Height; y++)
{
//map.SetPixel(x, y, Color.FromArgb(y, SelectedColor.R, SelectedColor.G, SelectedColor.B));
if (vertical)
{
map.SetPixel(x, y, Color.FromArgb(y, y, y, y));
}
else
{
map.SetPixel(x, y, Color.FromArgb(x, x, x, x));
}
}
}
return map;
}
private Bitmap RefreshSelectedColorMap(Size size)
{
Bitmap bmp = new Bitmap(size.Width, size.Height);
Graphics gr = Graphics.FromImage(bmp);
gr.FillRectangle(new SolidBrush(SelectedColor), new Rectangle(0, 0, size.Width, size.Height));
return bmp;
}
private void RefreshUi()
{
pbxColor.Image = RefreshMap(colorMap);
tbrRedLevel.Value = RedLevel;
Color Scol = Color.FromArgb(SelectedColor.A, SelectedColor.R, SelectedColor.G, SelectedColor.B);
pbxColor.Image = RefreshMap(pbxColor.Size);
pbxSliderRed.Image = RefreshRedLevel(pbxSliderRed.Size,false);
pbxSliderSaturation.Image = RefreshGammaLevel(pbxSliderSaturation.Size,true);
pbxSelectedColor.Image = RefreshSelectedColorMap(pbxSelectedColor.Size);
nupRed.Value = Scol.R;
nupGreen.Value = Scol.G;
nupBlue.Value = Scol.B;
nupGamma.Value = Scol.A;
pbxSelectedColor.BackColor = SelectedColor;
tbxColorHex.Text = ColorToHex(Scol);
}
private void tbrRedLevel_Scroll(object sender, EventArgs e)
{
RedLevel = tbrRedLevel.Value;
//RedLevel = tbrRedLevel.Value;
RefreshUi();
}
private void pbxColor_Click(object sender, EventArgs e)
{
//Bitmap img = (Bitmap)pbxColor.Image;
cursorLocation = pbxColor.PointToClient(MousePosition);
SelectedColor = colorMap.GetPixel(cursorLocation.X, cursorLocation.Y);
SelectedColor = (pbxColor.Image as Bitmap).GetPixel(cursorLocation.X, cursorLocation.Y);
RefreshUi();
}
private void pbxSliderRed_Click(object sender, EventArgs e)
{
SelectedColor = Color.FromArgb(SelectedColor.A,pbxSliderRed.PointToClient(MousePosition).X,SelectedColor.G,SelectedColor.B);
RefreshUi();
}
private void pbxSliderSaturation_Click(object sender, EventArgs e)
{
SelectedColor = Color.FromArgb(pbxSliderSaturation.PointToClient(MousePosition).Y, SelectedColor.R, SelectedColor.G, SelectedColor.B);
RefreshUi();
//MessageBox.Show(cursorLocation.ToString()+Environment.NewLine+SelectedColor.ToString());
}
public static Color HexToColor(string rgb)
{
@@ -138,7 +195,6 @@ namespace Paint_2
if (SelectedColor != newColor)
{
SelectedColor = newColor;
RedLevel = tmpR;
RefreshUi();
}
}
@@ -152,7 +208,6 @@ namespace Paint_2
if (SelectedColor != tmp)
{
SelectedColor = tmp;
RedLevel = tmp.R;
}
}
}
@@ -169,5 +224,10 @@ namespace Paint_2
RefreshUi();
}
}
private void ColorPicker_Shown(object sender, EventArgs e)
{
RefreshUi();
}
}
}

View File

@@ -66,6 +66,7 @@
this.label2 = new System.Windows.Forms.Label();
this.lsbTools = new System.Windows.Forms.ListBox();
this.btnColorPicker = new System.Windows.Forms.Button();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
this.panelFile.SuspendLayout();
this.panelDrawing.SuspendLayout();
@@ -214,7 +215,7 @@
this.panelSelectedColor.Controls.Add(this.btnSelectedColor);
this.panelSelectedColor.Controls.Add(this.lblSelectedColor);
this.panelSelectedColor.Controls.Add(this.label14);
this.panelSelectedColor.Location = new System.Drawing.Point(382, 606);
this.panelSelectedColor.Location = new System.Drawing.Point(382, 645);
this.panelSelectedColor.Name = "panelSelectedColor";
this.panelSelectedColor.Size = new System.Drawing.Size(363, 50);
this.panelSelectedColor.TabIndex = 31;
@@ -247,7 +248,7 @@
this.panelHoverColor.Controls.Add(this.btnHoveringColor);
this.panelHoverColor.Controls.Add(this.lblHoveringColor);
this.panelHoverColor.Controls.Add(this.label15);
this.panelHoverColor.Location = new System.Drawing.Point(12, 606);
this.panelHoverColor.Location = new System.Drawing.Point(12, 645);
this.panelHoverColor.Name = "panelHoverColor";
this.panelHoverColor.Size = new System.Drawing.Size(370, 50);
this.panelHoverColor.TabIndex = 32;
@@ -394,7 +395,7 @@
this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnClear.Font = new System.Drawing.Font("Cascadia Code", 10.5F);
this.btnClear.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.btnClear.Location = new System.Drawing.Point(926, 606);
this.btnClear.Location = new System.Drawing.Point(942, 645);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(163, 48);
this.btnClear.TabIndex = 27;
@@ -431,7 +432,7 @@
this.panelTools.Controls.Add(this.label5);
this.panelTools.Controls.Add(this.label9);
this.panelTools.Controls.Add(this.nupPencilWidth);
this.panelTools.Location = new System.Drawing.Point(927, 7);
this.panelTools.Location = new System.Drawing.Point(943, 7);
this.panelTools.Name = "panelTools";
this.panelTools.Size = new System.Drawing.Size(163, 593);
this.panelTools.TabIndex = 31;
@@ -521,7 +522,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.ClientSize = new System.Drawing.Size(1095, 663);
this.ClientSize = new System.Drawing.Size(1111, 702);
this.Controls.Add(this.panelHoverColor);
this.Controls.Add(this.panelSelectedColor);
this.Controls.Add(this.panelTools);
@@ -529,6 +530,7 @@
this.Controls.Add(this.panelFile);
this.Controls.Add(this.btnClear);
this.Controls.Add(this.canvas);
this.DoubleBuffered = true;
this.Font = new System.Drawing.Font("Cascadia Code", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.Margin = new System.Windows.Forms.Padding(4);
@@ -591,6 +593,7 @@
private System.Windows.Forms.Button btnUndo;
private System.Windows.Forms.Button btnRedo;
private System.Windows.Forms.Button btnColorPicker;
private System.Windows.Forms.ColorDialog colorDialog1;
}
}

View File

@@ -83,7 +83,6 @@ namespace Paint_2
{
// Expected Hex:FFFFFF R:255 G:255 B:255
string result = "";
int toBase = 16;
result += ColorPicker.ColorToHex(color);
result += " ";
result += "R:" + color.R + " G:" + color.G + " B:" + color.B;
@@ -222,7 +221,9 @@ namespace Paint_2
private void btnColorPicker_Click(object sender, EventArgs e)
{
ColorPicker cp = new ColorPicker(this);
cp.ShowDialog();
//ColorDialog cd = new ColorDialog();
cp.Show();
//cd.ShowDialog();
}
}
}

View File

@@ -120,4 +120,7 @@
<metadata name="tmrRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>128, 17</value>
</metadata>
</root>

View File

@@ -68,7 +68,7 @@ namespace Paint_2
}
catch (Exception ex)
{
Console.WriteLine("Oooops...");
Console.WriteLine("Oooops... " + ex);
}
}
public void Undo()