Removed the old Color changing and use the new functions from the color picker in form1.cs

This commit is contained in:
2022-06-07 11:56:43 +02:00
parent 510fc2a351
commit 0f4d845fd8
3 changed files with 41 additions and 246 deletions

View File

@@ -28,7 +28,9 @@ namespace Paint_2
private void ColorPicker_Load(object sender, EventArgs e) private void ColorPicker_Load(object sender, EventArgs e)
{ {
colorMap = new Bitmap(255, 255); colorMap = new Bitmap(255, 255);
SelectedColor = this.BackColor; //SelectedColor = this.BackColor;
SelectedColor = main.sketch.CurrentTool.Color;
RedLevel = SelectedColor.R;
RefreshUi(); RefreshUi();
} }
private Bitmap RefreshMap(Bitmap map) private Bitmap RefreshMap(Bitmap map)
@@ -45,14 +47,16 @@ namespace Paint_2
} }
private void RefreshUi() private void RefreshUi()
{ {
pbxColor.Image = RefreshMap(colorMap); pbxColor.Image = RefreshMap(colorMap);
Color Scol = Color.FromArgb(SelectedColor.A, SelectedColor.R, SelectedColor.G, SelectedColor.B);
tbrRedLevel.Value = RedLevel; tbrRedLevel.Value = RedLevel;
pbxSelectedColor.BackColor = Scol; Color Scol = Color.FromArgb(SelectedColor.A, SelectedColor.R, SelectedColor.G, SelectedColor.B);
nupRed.Value = Scol.R; nupRed.Value = Scol.R;
nupGreen.Value = Scol.G; nupGreen.Value = Scol.G;
nupBlue.Value = Scol.B; nupBlue.Value = Scol.B;
nupGamma.Value = Scol.A; nupGamma.Value = Scol.A;
pbxSelectedColor.BackColor = SelectedColor;
tbxColorHex.Text = ColorToHex(Scol); tbxColorHex.Text = ColorToHex(Scol);
} }
@@ -70,10 +74,10 @@ namespace Paint_2
RefreshUi(); RefreshUi();
//MessageBox.Show(cursorLocation.ToString()+Environment.NewLine+SelectedColor.ToString()); //MessageBox.Show(cursorLocation.ToString()+Environment.NewLine+SelectedColor.ToString());
} }
private Color HexToColor(string rgb) public static Color HexToColor(string rgb)
{ {
int toBase = 16; int toBase = 16;
string raw = tbxColorHex.Text; string raw = rgb;
string cleaned = raw.Replace("#", String.Empty); string cleaned = raw.Replace("#", String.Empty);
Color result; Color result;
if (cleaned.Length == 6) if (cleaned.Length == 6)
@@ -97,7 +101,7 @@ namespace Paint_2
} }
return result; return result;
} }
private string ColorToHex(Color color) public static string ColorToHex(Color color)
{ {
int toBase = 16; int toBase = 16;
string result = "#"; string result = "#";

View File

@@ -49,13 +49,7 @@
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.nupGreen = new System.Windows.Forms.NumericUpDown();
this.nupBlue = new System.Windows.Forms.NumericUpDown();
this.nupRed = new System.Windows.Forms.NumericUpDown();
this.nupPencilWidth = new System.Windows.Forms.NumericUpDown(); this.nupPencilWidth = new System.Windows.Forms.NumericUpDown();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.btnColorHistory4 = new System.Windows.Forms.Button(); this.btnColorHistory4 = new System.Windows.Forms.Button();
@@ -63,11 +57,8 @@
this.btnColorHistory2 = new System.Windows.Forms.Button(); this.btnColorHistory2 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.btnColorHistory1 = new System.Windows.Forms.Button(); this.btnColorHistory1 = new System.Windows.Forms.Button();
this.tbxColorHex = new System.Windows.Forms.TextBox();
this.btnClear = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button();
this.label13 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label();
this.btnSetColor = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.panelTools = new System.Windows.Forms.Panel(); this.panelTools = new System.Windows.Forms.Panel();
this.btnRedo = new System.Windows.Forms.Button(); this.btnRedo = new System.Windows.Forms.Button();
this.btnUndo = new System.Windows.Forms.Button(); this.btnUndo = new System.Windows.Forms.Button();
@@ -80,9 +71,6 @@
this.panelDrawing.SuspendLayout(); this.panelDrawing.SuspendLayout();
this.panelSelectedColor.SuspendLayout(); this.panelSelectedColor.SuspendLayout();
this.panelHoverColor.SuspendLayout(); this.panelHoverColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nupGreen)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupBlue)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupRed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).BeginInit();
this.panelTools.SuspendLayout(); this.panelTools.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@@ -95,7 +83,7 @@
this.tbxProjectName.Location = new System.Drawing.Point(10, 24); this.tbxProjectName.Location = new System.Drawing.Point(10, 24);
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.tbxProjectName.Name = "tbxProjectName"; this.tbxProjectName.Name = "tbxProjectName";
this.tbxProjectName.Size = new System.Drawing.Size(230, 27); this.tbxProjectName.Size = new System.Drawing.Size(230, 23);
this.tbxProjectName.TabIndex = 0; this.tbxProjectName.TabIndex = 0;
this.tbxProjectName.Text = "Untitled Project"; this.tbxProjectName.Text = "Untitled Project";
// //
@@ -144,7 +132,7 @@
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 22); this.label1.Location = new System.Drawing.Point(6, 22);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(110, 22); this.label1.Size = new System.Drawing.Size(88, 18);
this.label1.TabIndex = 5; this.label1.TabIndex = 5;
this.label1.Text = "Dimensions"; this.label1.Text = "Dimensions";
// //
@@ -153,7 +141,7 @@
this.lblSelectedColor.AutoSize = true; this.lblSelectedColor.AutoSize = true;
this.lblSelectedColor.Location = new System.Drawing.Point(6, 22); this.lblSelectedColor.Location = new System.Drawing.Point(6, 22);
this.lblSelectedColor.Name = "lblSelectedColor"; this.lblSelectedColor.Name = "lblSelectedColor";
this.lblSelectedColor.Size = new System.Drawing.Size(290, 22); this.lblSelectedColor.Size = new System.Drawing.Size(232, 18);
this.lblSelectedColor.TabIndex = 1; this.lblSelectedColor.TabIndex = 1;
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255"; this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
// //
@@ -175,7 +163,7 @@
this.label10.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label10.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label10.Location = new System.Drawing.Point(6, 0); this.label10.Location = new System.Drawing.Point(6, 0);
this.label10.Name = "label10"; this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(50, 22); this.label10.Size = new System.Drawing.Size(40, 18);
this.label10.TabIndex = 29; this.label10.TabIndex = 29;
this.label10.Text = "File"; this.label10.Text = "File";
// //
@@ -196,7 +184,7 @@
this.lblHeight.AutoSize = true; this.lblHeight.AutoSize = true;
this.lblHeight.Location = new System.Drawing.Point(100, 24); this.lblHeight.Location = new System.Drawing.Point(100, 24);
this.lblHeight.Name = "lblHeight"; this.lblHeight.Name = "lblHeight";
this.lblHeight.Size = new System.Drawing.Size(130, 22); this.lblHeight.Size = new System.Drawing.Size(104, 18);
this.lblHeight.TabIndex = 34; this.lblHeight.TabIndex = 34;
this.lblHeight.Text = "Height: 2000"; this.lblHeight.Text = "Height: 2000";
// //
@@ -205,7 +193,7 @@
this.lblWidth.AutoSize = true; this.lblWidth.AutoSize = true;
this.lblWidth.Location = new System.Drawing.Point(100, 6); this.lblWidth.Location = new System.Drawing.Point(100, 6);
this.lblWidth.Name = "lblWidth"; this.lblWidth.Name = "lblWidth";
this.lblWidth.Size = new System.Drawing.Size(120, 22); this.lblWidth.Size = new System.Drawing.Size(96, 18);
this.lblWidth.TabIndex = 33; this.lblWidth.TabIndex = 33;
this.lblWidth.Text = "width: 2000"; this.lblWidth.Text = "width: 2000";
// //
@@ -215,7 +203,7 @@
this.label11.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label11.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label11.Location = new System.Drawing.Point(6, 0); this.label11.Location = new System.Drawing.Point(6, 0);
this.label11.Name = "label11"; this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(80, 22); this.label11.Size = new System.Drawing.Size(64, 18);
this.label11.TabIndex = 29; this.label11.TabIndex = 29;
this.label11.Text = "Drawing"; this.label11.Text = "Drawing";
// //
@@ -248,7 +236,7 @@
this.label14.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label14.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label14.Location = new System.Drawing.Point(6, 0); this.label14.Location = new System.Drawing.Point(6, 0);
this.label14.Name = "label14"; this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(150, 22); this.label14.Size = new System.Drawing.Size(120, 18);
this.label14.TabIndex = 29; this.label14.TabIndex = 29;
this.label14.Text = "Selected color"; this.label14.Text = "Selected color";
// //
@@ -280,7 +268,7 @@
this.lblHoveringColor.AutoSize = true; this.lblHoveringColor.AutoSize = true;
this.lblHoveringColor.Location = new System.Drawing.Point(6, 22); this.lblHoveringColor.Location = new System.Drawing.Point(6, 22);
this.lblHoveringColor.Name = "lblHoveringColor"; this.lblHoveringColor.Name = "lblHoveringColor";
this.lblHoveringColor.Size = new System.Drawing.Size(290, 22); this.lblHoveringColor.Size = new System.Drawing.Size(232, 18);
this.lblHoveringColor.TabIndex = 1; this.lblHoveringColor.TabIndex = 1;
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255"; this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
// //
@@ -290,7 +278,7 @@
this.label15.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label15.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label15.Location = new System.Drawing.Point(6, 0); this.label15.Location = new System.Drawing.Point(6, 0);
this.label15.Name = "label15"; this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(150, 22); this.label15.Size = new System.Drawing.Size(120, 18);
this.label15.TabIndex = 29; this.label15.TabIndex = 29;
this.label15.Text = "Hovering color"; this.label15.Text = "Hovering color";
// //
@@ -299,83 +287,20 @@
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);
// //
// nupGreen
//
this.nupGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.nupGreen.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupGreen.Font = new System.Drawing.Font("Cascadia Code", 9F, 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(10, 198);
this.nupGreen.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupGreen.Name = "nupGreen";
this.nupGreen.Size = new System.Drawing.Size(85, 21);
this.nupGreen.TabIndex = 14;
this.nupGreen.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// nupBlue
//
this.nupBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.nupBlue.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupBlue.Font = new System.Drawing.Font("Cascadia Code", 9F, 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(10, 229);
this.nupBlue.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupBlue.Name = "nupBlue";
this.nupBlue.Size = new System.Drawing.Size(85, 21);
this.nupBlue.TabIndex = 15;
this.nupBlue.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// nupRed
//
this.nupRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.nupRed.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupRed.Font = new System.Drawing.Font("Cascadia Code", 9F, 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(10, 167);
this.nupRed.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nupRed.Name = "nupRed";
this.nupRed.Size = new System.Drawing.Size(85, 21);
this.nupRed.TabIndex = 13;
this.nupRed.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// nupPencilWidth // nupPencilWidth
// //
this.nupPencilWidth.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); this.nupPencilWidth.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.nupPencilWidth.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupPencilWidth.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupPencilWidth.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.nupPencilWidth.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupPencilWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); this.nupPencilWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupPencilWidth.Location = new System.Drawing.Point(10, 309); this.nupPencilWidth.Location = new System.Drawing.Point(9, 161);
this.nupPencilWidth.Maximum = new decimal(new int[] { this.nupPencilWidth.Maximum = new decimal(new int[] {
255, 255,
0, 0,
0, 0,
0}); 0});
this.nupPencilWidth.Name = "nupPencilWidth"; this.nupPencilWidth.Name = "nupPencilWidth";
this.nupPencilWidth.Size = new System.Drawing.Size(141, 21); this.nupPencilWidth.Size = new System.Drawing.Size(141, 17);
this.nupPencilWidth.TabIndex = 17; this.nupPencilWidth.TabIndex = 17;
this.nupPencilWidth.Value = new decimal(new int[] { this.nupPencilWidth.Value = new decimal(new int[] {
10, 10,
@@ -384,53 +309,23 @@
0}); 0});
this.nupPencilWidth.ValueChanged += new System.EventHandler(this.nupPencilWidth_ValueChanged); this.nupPencilWidth.ValueChanged += new System.EventHandler(this.nupPencilWidth_ValueChanged);
// //
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(10, 144);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(36, 20);
this.label7.TabIndex = 12;
this.label7.Text = "RGB";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(30, 257);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(99, 20);
this.label8.TabIndex = 18;
this.label8.Text = "Set pencil";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(10, 93);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(36, 20);
this.label6.TabIndex = 11;
this.label6.Text = "Hex";
//
// label9 // label9
// //
this.label9.AutoSize = true; this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label9.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(10, 286); this.label9.Location = new System.Drawing.Point(7, 142);
this.label9.Name = "label9"; this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(54, 20); this.label9.Size = new System.Drawing.Size(77, 16);
this.label9.TabIndex = 19; this.label9.TabIndex = 19;
this.label9.Text = "Width"; this.label9.Text = "Tool width";
// //
// label5 // label5
// //
this.label5.AutoSize = true; this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(30, 73); this.label5.Location = new System.Drawing.Point(10, 73);
this.label5.Name = "label5"; this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(90, 20); this.label5.Size = new System.Drawing.Size(70, 16);
this.label5.TabIndex = 9; this.label5.TabIndex = 9;
this.label5.Text = "Set color"; this.label5.Text = "Set color";
// //
@@ -476,7 +371,7 @@
this.label4.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(10, 25); this.label4.Location = new System.Drawing.Point(10, 25);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(135, 20); this.label4.Size = new System.Drawing.Size(105, 16);
this.label4.TabIndex = 1; this.label4.TabIndex = 1;
this.label4.Text = "Colors history"; this.label4.Text = "Colors history";
// //
@@ -492,18 +387,6 @@
this.btnColorHistory1.UseVisualStyleBackColor = false; this.btnColorHistory1.UseVisualStyleBackColor = false;
this.btnColorHistory1.Click += new System.EventHandler(this.BtnColor_Click); this.btnColorHistory1.Click += new System.EventHandler(this.BtnColor_Click);
// //
// tbxColorHex
//
this.tbxColorHex.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.tbxColorHex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxColorHex.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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.Name = "tbxColorHex";
this.tbxColorHex.Size = new System.Drawing.Size(85, 25);
this.tbxColorHex.TabIndex = 10;
this.tbxColorHex.Text = "#FFFFFF";
//
// btnClear // btnClear
// //
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -525,51 +408,21 @@
this.label13.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label13.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label13.Location = new System.Drawing.Point(6, 0); this.label13.Location = new System.Drawing.Point(6, 0);
this.label13.Name = "label13"; this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(60, 22); this.label13.Size = new System.Drawing.Size(48, 18);
this.label13.TabIndex = 29; this.label13.TabIndex = 29;
this.label13.Text = "Tools"; this.label13.Text = "Tools";
// //
// 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);
//
// 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);
//
// panelTools // panelTools
// //
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.panelTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.panelTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panelTools.Controls.Add(this.btnColorPicker);
this.panelTools.Controls.Add(this.btnRedo); this.panelTools.Controls.Add(this.btnRedo);
this.panelTools.Controls.Add(this.btnUndo); this.panelTools.Controls.Add(this.btnUndo);
this.panelTools.Controls.Add(this.btnRandomColor); this.panelTools.Controls.Add(this.btnRandomColor);
this.panelTools.Controls.Add(this.label2); this.panelTools.Controls.Add(this.label2);
this.panelTools.Controls.Add(this.lsbTools); this.panelTools.Controls.Add(this.lsbTools);
this.panelTools.Controls.Add(this.button1);
this.panelTools.Controls.Add(this.btnSetColor);
this.panelTools.Controls.Add(this.label13); this.panelTools.Controls.Add(this.label13);
this.panelTools.Controls.Add(this.tbxColorHex);
this.panelTools.Controls.Add(this.btnColorHistory1); this.panelTools.Controls.Add(this.btnColorHistory1);
this.panelTools.Controls.Add(this.label4); this.panelTools.Controls.Add(this.label4);
this.panelTools.Controls.Add(this.btnColorHistory2); this.panelTools.Controls.Add(this.btnColorHistory2);
@@ -577,13 +430,7 @@
this.panelTools.Controls.Add(this.btnColorHistory4); this.panelTools.Controls.Add(this.btnColorHistory4);
this.panelTools.Controls.Add(this.label5); this.panelTools.Controls.Add(this.label5);
this.panelTools.Controls.Add(this.label9); this.panelTools.Controls.Add(this.label9);
this.panelTools.Controls.Add(this.label6);
this.panelTools.Controls.Add(this.label8);
this.panelTools.Controls.Add(this.label7);
this.panelTools.Controls.Add(this.nupPencilWidth); this.panelTools.Controls.Add(this.nupPencilWidth);
this.panelTools.Controls.Add(this.nupRed);
this.panelTools.Controls.Add(this.nupBlue);
this.panelTools.Controls.Add(this.nupGreen);
this.panelTools.Location = new System.Drawing.Point(927, 7); this.panelTools.Location = new System.Drawing.Point(927, 7);
this.panelTools.Name = "panelTools"; this.panelTools.Name = "panelTools";
this.panelTools.Size = new System.Drawing.Size(163, 593); this.panelTools.Size = new System.Drawing.Size(163, 593);
@@ -609,7 +456,7 @@
this.btnUndo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnUndo.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnUndo.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnUndo.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnUndo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); this.btnUndo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.btnUndo.Location = new System.Drawing.Point(3, 547); this.btnUndo.Location = new System.Drawing.Point(4, 547);
this.btnUndo.Name = "btnUndo"; this.btnUndo.Name = "btnUndo";
this.btnUndo.Size = new System.Drawing.Size(75, 43); this.btnUndo.Size = new System.Drawing.Size(75, 43);
this.btnUndo.TabIndex = 35; this.btnUndo.TabIndex = 35;
@@ -635,9 +482,9 @@
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(10, 335); this.label2.Location = new System.Drawing.Point(6, 181);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(54, 20); this.label2.Size = new System.Drawing.Size(42, 16);
this.label2.TabIndex = 33; this.label2.TabIndex = 33;
this.label2.Text = "Tools"; this.label2.Text = "Tools";
// //
@@ -647,10 +494,10 @@
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.lsbTools.FormattingEnabled = true; this.lsbTools.FormattingEnabled = true;
this.lsbTools.ItemHeight = 22; this.lsbTools.ItemHeight = 18;
this.lsbTools.Location = new System.Drawing.Point(10, 358); this.lsbTools.Location = new System.Drawing.Point(10, 204);
this.lsbTools.Name = "lsbTools"; this.lsbTools.Name = "lsbTools";
this.lsbTools.Size = new System.Drawing.Size(141, 178); this.lsbTools.Size = new System.Drawing.Size(141, 164);
this.lsbTools.TabIndex = 32; this.lsbTools.TabIndex = 32;
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged); this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
// //
@@ -661,9 +508,9 @@
this.btnColorPicker.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnColorPicker.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnColorPicker.Font = new System.Drawing.Font("Cascadia Code", 10.5F); this.btnColorPicker.Font = new System.Drawing.Font("Cascadia Code", 10.5F);
this.btnColorPicker.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); this.btnColorPicker.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.btnColorPicker.Location = new System.Drawing.Point(758, 12); this.btnColorPicker.Location = new System.Drawing.Point(9, 92);
this.btnColorPicker.Name = "btnColorPicker"; this.btnColorPicker.Name = "btnColorPicker";
this.btnColorPicker.Size = new System.Drawing.Size(163, 48); this.btnColorPicker.Size = new System.Drawing.Size(141, 31);
this.btnColorPicker.TabIndex = 33; this.btnColorPicker.TabIndex = 33;
this.btnColorPicker.Text = "ColorPicker"; this.btnColorPicker.Text = "ColorPicker";
this.btnColorPicker.UseVisualStyleBackColor = false; this.btnColorPicker.UseVisualStyleBackColor = false;
@@ -671,11 +518,10 @@
// //
// PaintForm // PaintForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 22F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); 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(1095, 663);
this.Controls.Add(this.btnColorPicker);
this.Controls.Add(this.panelHoverColor); this.Controls.Add(this.panelHoverColor);
this.Controls.Add(this.panelSelectedColor); this.Controls.Add(this.panelSelectedColor);
this.Controls.Add(this.panelTools); this.Controls.Add(this.panelTools);
@@ -699,9 +545,6 @@
this.panelSelectedColor.PerformLayout(); this.panelSelectedColor.PerformLayout();
this.panelHoverColor.ResumeLayout(false); this.panelHoverColor.ResumeLayout(false);
this.panelHoverColor.PerformLayout(); this.panelHoverColor.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nupGreen)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupBlue)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupRed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).EndInit();
this.panelTools.ResumeLayout(false); this.panelTools.ResumeLayout(false);
this.panelTools.PerformLayout(); this.panelTools.PerformLayout();
@@ -729,13 +572,7 @@
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.NumericUpDown nupGreen;
private System.Windows.Forms.NumericUpDown nupBlue;
private System.Windows.Forms.NumericUpDown nupRed;
private System.Windows.Forms.NumericUpDown nupPencilWidth; private System.Windows.Forms.NumericUpDown nupPencilWidth;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button btnColorHistory4; private System.Windows.Forms.Button btnColorHistory4;
@@ -743,11 +580,8 @@
private System.Windows.Forms.Button btnColorHistory2; private System.Windows.Forms.Button btnColorHistory2;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btnColorHistory1; private System.Windows.Forms.Button btnColorHistory1;
private System.Windows.Forms.TextBox tbxColorHex;
private System.Windows.Forms.Button btnClear; private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Label label13; private System.Windows.Forms.Label label13;
private System.Windows.Forms.Button btnSetColor;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panelTools; private System.Windows.Forms.Panel panelTools;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.ListBox lsbTools; private System.Windows.Forms.ListBox lsbTools;

View File

@@ -84,7 +84,8 @@ namespace Paint_2
// Expected Hex:FFFFFF R:255 G:255 B:255 // Expected Hex:FFFFFF R:255 G:255 B:255
string result = ""; string result = "";
int toBase = 16; int toBase = 16;
result += "Hex:" + Convert.ToString(color.R, toBase) + Convert.ToString(color.G, toBase) + Convert.ToString(color.B, toBase) + " "; result += ColorPicker.ColorToHex(color);
result += " ";
result += "R:" + color.R + " G:" + color.G + " B:" + color.B; result += "R:" + color.R + " G:" + color.G + " B:" + color.B;
return result; return result;
} }
@@ -149,50 +150,6 @@ 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;
int fromBase = 16;
value = value.Replace("#", String.Empty);
int R, G, B;
try
{
R = Convert.ToInt32(String.Concat(value[0], value[1]), fromBase);
G = Convert.ToInt32(String.Concat(value[2], value[3]), fromBase);
B = Convert.ToInt32(String.Concat(value[4], value[4]), fromBase);
}
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));
}
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
string fileName = tbxProjectName.Text; string fileName = tbxProjectName.Text;