Added the full ability to set the color

This commit is contained in:
2022-05-25 15:11:29 +02:00
parent 682efbfef7
commit 8b7c63a40b
2 changed files with 93 additions and 16 deletions

View File

@@ -67,15 +67,17 @@
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.label11 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.btnSetColor = new System.Windows.Forms.Button();
this.label13 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel(); this.panel4 = new System.Windows.Forms.Panel();
this.btnSelectedColor = new System.Windows.Forms.Button();
this.label14 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel(); this.panel5 = new System.Windows.Forms.Panel();
this.btnHoveringColor = new System.Windows.Forms.Button(); this.btnHoveringColor = new System.Windows.Forms.Button();
this.lblHoveringColor = new System.Windows.Forms.Label(); this.lblHoveringColor = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label();
this.tmrRefresh = new System.Windows.Forms.Timer(this.components); this.tmrRefresh = new System.Windows.Forms.Timer(this.components);
this.btnSelectedColor = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupHeight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nupHeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupWidth)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nupWidth)).BeginInit();
@@ -290,7 +292,7 @@
this.tbxColorHex.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); this.tbxColorHex.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.tbxColorHex.Location = new System.Drawing.Point(10, 116); this.tbxColorHex.Location = new System.Drawing.Point(10, 116);
this.tbxColorHex.Name = "tbxColorHex"; this.tbxColorHex.Name = "tbxColorHex";
this.tbxColorHex.Size = new System.Drawing.Size(141, 25); this.tbxColorHex.Size = new System.Drawing.Size(85, 25);
this.tbxColorHex.TabIndex = 10; this.tbxColorHex.TabIndex = 10;
this.tbxColorHex.Text = "#FFFFFF"; this.tbxColorHex.Text = "#FFFFFF";
// //
@@ -327,7 +329,7 @@
0, 0,
0}); 0});
this.nupRed.Name = "nupRed"; this.nupRed.Name = "nupRed";
this.nupRed.Size = new System.Drawing.Size(141, 21); this.nupRed.Size = new System.Drawing.Size(85, 21);
this.nupRed.TabIndex = 13; this.nupRed.TabIndex = 13;
this.nupRed.Value = new decimal(new int[] { this.nupRed.Value = new decimal(new int[] {
255, 255,
@@ -348,7 +350,7 @@
0, 0,
0}); 0});
this.nupGreen.Name = "nupGreen"; this.nupGreen.Name = "nupGreen";
this.nupGreen.Size = new System.Drawing.Size(141, 21); this.nupGreen.Size = new System.Drawing.Size(85, 21);
this.nupGreen.TabIndex = 14; this.nupGreen.TabIndex = 14;
this.nupGreen.Value = new decimal(new int[] { this.nupGreen.Value = new decimal(new int[] {
255, 255,
@@ -369,7 +371,7 @@
0, 0,
0}); 0});
this.nupBlue.Name = "nupBlue"; this.nupBlue.Name = "nupBlue";
this.nupBlue.Size = new System.Drawing.Size(141, 21); this.nupBlue.Size = new System.Drawing.Size(85, 21);
this.nupBlue.TabIndex = 15; this.nupBlue.TabIndex = 15;
this.nupBlue.Value = new decimal(new int[] { this.nupBlue.Value = new decimal(new int[] {
255, 255,
@@ -582,6 +584,8 @@
// panel3 // panel3
// //
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panel3.Controls.Add(this.button1);
this.panel3.Controls.Add(this.btnSetColor);
this.panel3.Controls.Add(this.btnFill); this.panel3.Controls.Add(this.btnFill);
this.panel3.Controls.Add(this.label13); this.panel3.Controls.Add(this.label13);
this.panel3.Controls.Add(this.btnClear); this.panel3.Controls.Add(this.btnClear);
@@ -611,6 +615,34 @@
this.panel3.Size = new System.Drawing.Size(163, 642); this.panel3.Size = new System.Drawing.Size(163, 642);
this.panel3.TabIndex = 31; this.panel3.TabIndex = 31;
// //
// button1
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.button1.Location = new System.Drawing.Point(101, 167);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 83);
this.button1.TabIndex = 31;
this.button1.Text = "Set";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// btnSetColor
//
this.btnSetColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.btnSetColor.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSetColor.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSetColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.btnSetColor.Location = new System.Drawing.Point(101, 113);
this.btnSetColor.Name = "btnSetColor";
this.btnSetColor.Size = new System.Drawing.Size(56, 31);
this.btnSetColor.TabIndex = 30;
this.btnSetColor.Text = "Set";
this.btnSetColor.UseVisualStyleBackColor = false;
this.btnSetColor.Click += new System.EventHandler(this.btnSetColor_Click);
//
// label13 // label13
// //
this.label13.AutoSize = true; this.label13.AutoSize = true;
@@ -632,6 +664,17 @@
this.panel4.Size = new System.Drawing.Size(363, 50); this.panel4.Size = new System.Drawing.Size(363, 50);
this.panel4.TabIndex = 31; this.panel4.TabIndex = 31;
// //
// btnSelectedColor
//
this.btnSelectedColor.BackColor = System.Drawing.Color.Green;
this.btnSelectedColor.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSelectedColor.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSelectedColor.Location = new System.Drawing.Point(302, -2);
this.btnSelectedColor.Name = "btnSelectedColor";
this.btnSelectedColor.Size = new System.Drawing.Size(55, 55);
this.btnSelectedColor.TabIndex = 31;
this.btnSelectedColor.UseVisualStyleBackColor = false;
//
// label14 // label14
// //
this.label14.AutoSize = true; this.label14.AutoSize = true;
@@ -688,17 +731,6 @@
this.tmrRefresh.Interval = 1; this.tmrRefresh.Interval = 1;
this.tmrRefresh.Tick += new System.EventHandler(this.tmrRefresh_Tick); this.tmrRefresh.Tick += new System.EventHandler(this.tmrRefresh_Tick);
// //
// btnSelectedColor
//
this.btnSelectedColor.BackColor = System.Drawing.Color.Green;
this.btnSelectedColor.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSelectedColor.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSelectedColor.Location = new System.Drawing.Point(302, -2);
this.btnSelectedColor.Name = "btnSelectedColor";
this.btnSelectedColor.Size = new System.Drawing.Size(55, 55);
this.btnSelectedColor.TabIndex = 31;
this.btnSelectedColor.UseVisualStyleBackColor = false;
//
// PaintForm // PaintForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 22F); this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 22F);
@@ -787,6 +819,8 @@
private System.Windows.Forms.Timer tmrRefresh; private System.Windows.Forms.Timer tmrRefresh;
private System.Windows.Forms.Button btnHoveringColor; private System.Windows.Forms.Button btnHoveringColor;
private System.Windows.Forms.Button btnSelectedColor; private System.Windows.Forms.Button btnSelectedColor;
private System.Windows.Forms.Button btnSetColor;
private System.Windows.Forms.Button button1;
} }
} }

View File

@@ -114,5 +114,48 @@ namespace Paint_2
{ {
sketch.ChangePaintToolWidth((int)nupPencilWidth.Value); sketch.ChangePaintToolWidth((int)nupPencilWidth.Value);
} }
private void btnSetColor_Click(object sender, EventArgs e)
{
string value = tbxColorHex.Text;
value = value.Replace("#", String.Empty);
int R, G, B;
try
{
R = Convert.ToInt32(value[0] + value[1]);
G = Convert.ToInt32(value[2] + value[3]);
B = Convert.ToInt32(value[4] + value[5]);
}
catch (Exception exception)
{
MessageBox.Show("Please enter a valid hexadecimal value");
tbxColorHex.Text = "#FFFFFF";
R = 255;
G = 255;
B = 255;
}
sketch.ChangePaintToolColor(Color.FromArgb(R, G, B));
}
private void button1_Click(object sender, EventArgs e)
{
int R, G, B;
R = (int)nupRed.Value;
G = (int)nupGreen.Value;
B = (int)nupBlue.Value;
if (R > 255)
{
R = 255;
}
if (G > 255)
{
G = 25;
}
if(B > 255)
{
B = 255;
}
sketch.ChangePaintToolColor(Color.FromArgb(R, G, B));
}
} }
} }