diff --git a/Paint_2/BezierPencil.cs b/Paint_2/BezierPencil.cs index b262347..ccda593 100644 --- a/Paint_2/BezierPencil.cs +++ b/Paint_2/BezierPencil.cs @@ -80,7 +80,6 @@ namespace Paint_2 for (int i = 1; i <= points.Count; i++) { - pointSize = new Size(Widths[0], Widths[0]); gr.FillEllipse(new SolidBrush(Colors[i - 1]), new Rectangle(new Point(points[i - 1].X - pointSize.Width / 2, points[i - 1].Y - pointSize.Height / 2), pointSize)); ContinuousBezierGenerator(gr, points, i); diff --git a/Paint_2/ColorPicker.Designer.cs b/Paint_2/ColorPicker.Designer.cs new file mode 100644 index 0000000..dde5b07 --- /dev/null +++ b/Paint_2/ColorPicker.Designer.cs @@ -0,0 +1,263 @@ +namespace Paint_2 +{ + partial class ColorPicker + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(); + ((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(); + this.SuspendLayout(); + // + // pbxColor + // + this.pbxColor.Location = new System.Drawing.Point(13, 13); + this.pbxColor.Margin = new System.Windows.Forms.Padding(4); + this.pbxColor.Name = "pbxColor"; + this.pbxColor.Size = new System.Drawing.Size(255, 255); + this.pbxColor.TabIndex = 0; + 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.Name = "pbxSelectedColor"; + this.pbxSelectedColor.Size = new System.Drawing.Size(255, 50); + 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.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.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.nupRed.Name = "nupRed"; + this.nupRed.Size = new System.Drawing.Size(60, 22); + 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.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.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.nupGreen.Name = "nupGreen"; + this.nupGreen.Size = new System.Drawing.Size(60, 22); + 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.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.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.nupBlue.Name = "nupBlue"; + this.nupBlue.Size = new System.Drawing.Size(60, 22); + 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.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.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.nupGamma.Name = "nupGamma"; + this.nupGamma.Size = new System.Drawing.Size(60, 22); + 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.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.Name = "tbxColorHex"; + this.tbxColorHex.Size = new System.Drawing.Size(257, 23); + this.tbxColorHex.TabIndex = 20; + this.tbxColorHex.TextChanged += new System.EventHandler(this.tbxColorHex_TextChanged); + this.tbxColorHex.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxColorHex_KeyDown); + // + // ColorPicker + // + 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(280, 481); + this.Controls.Add(this.tbxColorHex); + 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.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.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); + ((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(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #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; + } +} \ No newline at end of file diff --git a/Paint_2/ColorPicker.cs b/Paint_2/ColorPicker.cs new file mode 100644 index 0000000..082a59a --- /dev/null +++ b/Paint_2/ColorPicker.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +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; + public ColorPicker(PaintForm theMainForm) + { + InitializeComponent(); + main = theMainForm; + } + + private void ColorPicker_Load(object sender, EventArgs e) + { + colorMap = new Bitmap(255, 255); + SelectedColor = this.BackColor; + RefreshUi(); + } + private Bitmap RefreshMap(Bitmap map) + { + Graphics gr = Graphics.FromImage(map); + for (int g = 0; g < 255; g += 1) + { + for (int b = 0; b < 255; b += 1) + { + map.SetPixel(g, b, Color.FromArgb(255, RedLevel, g, b)); + } + } + return map; + } + private void RefreshUi() + { + pbxColor.Image = RefreshMap(colorMap); + Color Scol = Color.FromArgb(SelectedColor.A, SelectedColor.R, SelectedColor.G, SelectedColor.B); + tbrRedLevel.Value = RedLevel; + pbxSelectedColor.BackColor = Scol; + nupRed.Value = Scol.R; + nupGreen.Value = Scol.G; + nupBlue.Value = Scol.B; + nupGamma.Value = Scol.A; + tbxColorHex.Text = ColorToHex(Scol); + } + + private void tbrRedLevel_Scroll(object sender, EventArgs e) + { + 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); + RefreshUi(); + //MessageBox.Show(cursorLocation.ToString()+Environment.NewLine+SelectedColor.ToString()); + } + private Color HexToColor(string rgb) + { + int toBase = 16; + string raw = tbxColorHex.Text; + string cleaned = raw.Replace("#", String.Empty); + Color result; + if (cleaned.Length == 6) + { + try + { + int r = Convert.ToInt32(String.Concat(cleaned[0], cleaned[1]), toBase); + int g = Convert.ToInt32(String.Concat(cleaned[2], cleaned[3]), toBase); + int b = Convert.ToInt32(String.Concat(cleaned[4], cleaned[5]), toBase); + result = Color.FromArgb(r, g, b); + } + catch (Exception e) + { + Console.WriteLine(e); + result = default; + } + } + else + { + result = default; + } + return result; + } + private string ColorToHex(Color color) + { + int toBase = 16; + string result = "#"; + + if (color.R < toBase) + { + result += "0"; + } + result += Convert.ToString(color.R, toBase); + if (color.G < toBase) + { + result += "0"; + } + result += Convert.ToString(color.G, toBase); + if (color.B < toBase) + { + result += "0"; + } + result += Convert.ToString(color.B, toBase); + + return result; + } + + private void nupValueChanged(object sender, EventArgs e) + { + int tmpR = (int)nupRed.Value; + int tmpG = (int)nupGreen.Value; + int tmpB = (int)nupBlue.Value; + int tmpA = (int)nupGamma.Value; + + if (tmpR >= 0 && tmpR <= 255 && tmpG >= 0 && tmpG <= 255 && tmpB >= 0 && tmpB <= 255 && tmpA >= 0 && tmpA <= 255) + { + Color newColor = Color.FromArgb(tmpA, tmpR, tmpG, tmpB); + if (SelectedColor != newColor) + { + SelectedColor = newColor; + RedLevel = tmpR; + RefreshUi(); + } + } + } + + private void tbxColorHex_TextChanged(object sender, EventArgs e) + { + Color tmp = HexToColor(tbxColorHex.Text); + if (tmp != null) + { + if (SelectedColor != tmp) + { + SelectedColor = tmp; + RedLevel = tmp.R; + } + } + } + + private void ColorPicker_FormClosing(object sender, FormClosingEventArgs e) + { + main.sketch.ChangePaintToolColor(SelectedColor); + } + + private void tbxColorHex_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + RefreshUi(); + } + } + } +} diff --git a/Paint_2/ColorPicker.resx b/Paint_2/ColorPicker.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Paint_2/ColorPicker.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Paint_2/Form1.Designer.cs b/Paint_2/Form1.Designer.cs index 44de49f..b3ba487 100644 --- a/Paint_2/Form1.Designer.cs +++ b/Paint_2/Form1.Designer.cs @@ -74,6 +74,7 @@ this.btnRandomColor = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.lsbTools = new System.Windows.Forms.ListBox(); + this.btnColorPicker = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit(); this.panelFile.SuspendLayout(); this.panelDrawing.SuspendLayout(); @@ -94,7 +95,7 @@ this.tbxProjectName.Location = new System.Drawing.Point(10, 24); this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.tbxProjectName.Name = "tbxProjectName"; - this.tbxProjectName.Size = new System.Drawing.Size(230, 23); + this.tbxProjectName.Size = new System.Drawing.Size(230, 27); this.tbxProjectName.TabIndex = 0; this.tbxProjectName.Text = "Untitled Project"; // @@ -143,7 +144,7 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 22); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(88, 18); + this.label1.Size = new System.Drawing.Size(110, 22); this.label1.TabIndex = 5; this.label1.Text = "Dimensions"; // @@ -152,7 +153,7 @@ this.lblSelectedColor.AutoSize = true; this.lblSelectedColor.Location = new System.Drawing.Point(6, 22); this.lblSelectedColor.Name = "lblSelectedColor"; - this.lblSelectedColor.Size = new System.Drawing.Size(232, 18); + this.lblSelectedColor.Size = new System.Drawing.Size(290, 22); this.lblSelectedColor.TabIndex = 1; this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255"; // @@ -174,7 +175,7 @@ this.label10.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label10.Location = new System.Drawing.Point(6, 0); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(40, 18); + this.label10.Size = new System.Drawing.Size(50, 22); this.label10.TabIndex = 29; this.label10.Text = "File"; // @@ -195,7 +196,7 @@ this.lblHeight.AutoSize = true; this.lblHeight.Location = new System.Drawing.Point(100, 24); this.lblHeight.Name = "lblHeight"; - this.lblHeight.Size = new System.Drawing.Size(104, 18); + this.lblHeight.Size = new System.Drawing.Size(130, 22); this.lblHeight.TabIndex = 34; this.lblHeight.Text = "Height: 2000"; // @@ -204,7 +205,7 @@ this.lblWidth.AutoSize = true; this.lblWidth.Location = new System.Drawing.Point(100, 6); this.lblWidth.Name = "lblWidth"; - this.lblWidth.Size = new System.Drawing.Size(96, 18); + this.lblWidth.Size = new System.Drawing.Size(120, 22); this.lblWidth.TabIndex = 33; this.lblWidth.Text = "width: 2000"; // @@ -214,7 +215,7 @@ this.label11.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label11.Location = new System.Drawing.Point(6, 0); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(64, 18); + this.label11.Size = new System.Drawing.Size(80, 22); this.label11.TabIndex = 29; this.label11.Text = "Drawing"; // @@ -247,7 +248,7 @@ this.label14.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label14.Location = new System.Drawing.Point(6, 0); this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(120, 18); + this.label14.Size = new System.Drawing.Size(150, 22); this.label14.TabIndex = 29; this.label14.Text = "Selected color"; // @@ -279,7 +280,7 @@ this.lblHoveringColor.AutoSize = true; this.lblHoveringColor.Location = new System.Drawing.Point(6, 22); this.lblHoveringColor.Name = "lblHoveringColor"; - this.lblHoveringColor.Size = new System.Drawing.Size(232, 18); + this.lblHoveringColor.Size = new System.Drawing.Size(290, 22); this.lblHoveringColor.TabIndex = 1; this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255"; // @@ -289,7 +290,7 @@ this.label15.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label15.Location = new System.Drawing.Point(6, 0); this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(120, 18); + this.label15.Size = new System.Drawing.Size(150, 22); this.label15.TabIndex = 29; this.label15.Text = "Hovering color"; // @@ -311,7 +312,7 @@ 0, 0}); this.nupGreen.Name = "nupGreen"; - this.nupGreen.Size = new System.Drawing.Size(85, 17); + this.nupGreen.Size = new System.Drawing.Size(85, 21); this.nupGreen.TabIndex = 14; this.nupGreen.Value = new decimal(new int[] { 255, @@ -332,7 +333,7 @@ 0, 0}); this.nupBlue.Name = "nupBlue"; - this.nupBlue.Size = new System.Drawing.Size(85, 17); + this.nupBlue.Size = new System.Drawing.Size(85, 21); this.nupBlue.TabIndex = 15; this.nupBlue.Value = new decimal(new int[] { 255, @@ -353,7 +354,7 @@ 0, 0}); this.nupRed.Name = "nupRed"; - this.nupRed.Size = new System.Drawing.Size(85, 17); + this.nupRed.Size = new System.Drawing.Size(85, 21); this.nupRed.TabIndex = 13; this.nupRed.Value = new decimal(new int[] { 255, @@ -374,7 +375,7 @@ 0, 0}); this.nupPencilWidth.Name = "nupPencilWidth"; - this.nupPencilWidth.Size = new System.Drawing.Size(141, 17); + this.nupPencilWidth.Size = new System.Drawing.Size(141, 21); this.nupPencilWidth.TabIndex = 17; this.nupPencilWidth.Value = new decimal(new int[] { 10, @@ -389,7 +390,7 @@ 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(28, 16); + this.label7.Size = new System.Drawing.Size(36, 20); this.label7.TabIndex = 12; this.label7.Text = "RGB"; // @@ -399,7 +400,7 @@ 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(77, 16); + this.label8.Size = new System.Drawing.Size(99, 20); this.label8.TabIndex = 18; this.label8.Text = "Set pencil"; // @@ -409,7 +410,7 @@ 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(28, 16); + this.label6.Size = new System.Drawing.Size(36, 20); this.label6.TabIndex = 11; this.label6.Text = "Hex"; // @@ -419,7 +420,7 @@ 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.Name = "label9"; - this.label9.Size = new System.Drawing.Size(42, 16); + this.label9.Size = new System.Drawing.Size(54, 20); this.label9.TabIndex = 19; this.label9.Text = "Width"; // @@ -429,7 +430,7 @@ 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.Name = "label5"; - this.label5.Size = new System.Drawing.Size(70, 16); + this.label5.Size = new System.Drawing.Size(90, 20); this.label5.TabIndex = 9; this.label5.Text = "Set color"; // @@ -475,7 +476,7 @@ 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.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 16); + this.label4.Size = new System.Drawing.Size(135, 20); this.label4.TabIndex = 1; this.label4.Text = "Colors history"; // @@ -499,7 +500,7 @@ 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, 21); + this.tbxColorHex.Size = new System.Drawing.Size(85, 25); this.tbxColorHex.TabIndex = 10; this.tbxColorHex.Text = "#FFFFFF"; // @@ -524,7 +525,7 @@ this.label13.Font = new System.Drawing.Font("Cascadia Code", 10F); this.label13.Location = new System.Drawing.Point(6, 0); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(48, 18); + this.label13.Size = new System.Drawing.Size(60, 22); this.label13.TabIndex = 29; this.label13.Text = "Tools"; // @@ -636,7 +637,7 @@ 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.Name = "label2"; - this.label2.Size = new System.Drawing.Size(42, 16); + this.label2.Size = new System.Drawing.Size(54, 20); this.label2.TabIndex = 33; this.label2.Text = "Tools"; // @@ -646,19 +647,35 @@ 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.FormattingEnabled = true; - this.lsbTools.ItemHeight = 18; + this.lsbTools.ItemHeight = 22; this.lsbTools.Location = new System.Drawing.Point(10, 358); this.lsbTools.Name = "lsbTools"; - this.lsbTools.Size = new System.Drawing.Size(141, 182); + this.lsbTools.Size = new System.Drawing.Size(141, 178); this.lsbTools.TabIndex = 32; this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged); // + // btnColorPicker + // + this.btnColorPicker.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnColorPicker.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); + this.btnColorPicker.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + 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.Location = new System.Drawing.Point(758, 12); + this.btnColorPicker.Name = "btnColorPicker"; + this.btnColorPicker.Size = new System.Drawing.Size(163, 48); + this.btnColorPicker.TabIndex = 33; + this.btnColorPicker.Text = "ColorPicker"; + this.btnColorPicker.UseVisualStyleBackColor = false; + this.btnColorPicker.Click += new System.EventHandler(this.btnColorPicker_Click); + // // PaintForm // - 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(1095, 663); + this.Controls.Add(this.btnColorPicker); this.Controls.Add(this.panelHoverColor); this.Controls.Add(this.panelSelectedColor); this.Controls.Add(this.panelTools); @@ -739,6 +756,7 @@ private System.Windows.Forms.Button btnRandomColor; private System.Windows.Forms.Button btnUndo; private System.Windows.Forms.Button btnRedo; + private System.Windows.Forms.Button btnColorPicker; } } diff --git a/Paint_2/Form1.cs b/Paint_2/Form1.cs index a1b0ad0..45a2115 100644 --- a/Paint_2/Form1.cs +++ b/Paint_2/Form1.cs @@ -21,7 +21,7 @@ namespace Paint_2 { const int WINDOW_OFFSET = 10; const string DEFAULT_FILEPATH = "C:/Paint2/Drawings/"; - Sketch sketch; + public Sketch sketch; List toolList; bool drawing = false; bool randomColor = false; @@ -261,5 +261,11 @@ namespace Paint_2 sketch.Redo(); ForceRefresh(); } + + private void btnColorPicker_Click(object sender, EventArgs e) + { + ColorPicker cp = new ColorPicker(this); + cp.ShowDialog(); + } } } diff --git a/Paint_2/PaintTool.cs b/Paint_2/PaintTool.cs index dc7d37d..517cf56 100644 --- a/Paint_2/PaintTool.cs +++ b/Paint_2/PaintTool.cs @@ -12,7 +12,7 @@ using System.Drawing; namespace Paint_2 { - internal interface PaintTool + public interface PaintTool { List> Drawings { get; set; } List> DrawingsRedo { get; set; } diff --git a/Paint_2/Paint_2.csproj b/Paint_2/Paint_2.csproj index b687bf6..0515513 100644 --- a/Paint_2/Paint_2.csproj +++ b/Paint_2/Paint_2.csproj @@ -47,6 +47,12 @@ + + Form + + + ColorPicker.cs + Form @@ -60,6 +66,9 @@ + + ColorPicker.cs + Form1.cs diff --git a/Paint_2/Sketch.cs b/Paint_2/Sketch.cs index 4417a95..8ec7a86 100644 --- a/Paint_2/Sketch.cs +++ b/Paint_2/Sketch.cs @@ -13,7 +13,7 @@ using System.Drawing; namespace Paint_2 { - internal class Sketch + public class Sketch { List _toolList; PaintTool _currentTool;