From d1d1b4936edc4cb1c070c2bcfd204cd688bc95a3 Mon Sep 17 00:00:00 2001 From: maxluli Date: Wed, 8 Jun 2022 14:26:23 +0200 Subject: [PATCH] Added a little preview of the width and color next to the width selector --- Paint_2/Form1.Designer.cs | 46 +++++++++++++++++++-------------------- Paint_2/Form1.cs | 11 ++++++++++ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Paint_2/Form1.Designer.cs b/Paint_2/Form1.Designer.cs index f53e864..1eda01d 100644 --- a/Paint_2/Form1.Designer.cs +++ b/Paint_2/Form1.Designer.cs @@ -55,7 +55,7 @@ this.btnColorHistory1 = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button(); this.panelTools = new System.Windows.Forms.Panel(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.pbxSample = new System.Windows.Forms.PictureBox(); this.btnRandomColor = new System.Windows.Forms.Button(); this.btnColorPicker = new System.Windows.Forms.Button(); this.btnRedo = new System.Windows.Forms.Button(); @@ -77,7 +77,7 @@ this.panelHoverColor.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).BeginInit(); this.panelTools.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbxSample)).BeginInit(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.panel3.SuspendLayout(); @@ -89,7 +89,7 @@ this.tbxProjectName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tbxProjectName.Font = new System.Drawing.Font("Verdana", 15F); this.tbxProjectName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); - this.tbxProjectName.Location = new System.Drawing.Point(11, 5); + this.tbxProjectName.Location = new System.Drawing.Point(11, 3); this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.tbxProjectName.Name = "tbxProjectName"; this.tbxProjectName.Size = new System.Drawing.Size(253, 38); @@ -101,7 +101,7 @@ this.btnSave.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnSave.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); - this.btnSave.Location = new System.Drawing.Point(315, 166); + this.btnSave.Location = new System.Drawing.Point(268, 3); this.btnSave.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(82, 39); @@ -114,7 +114,7 @@ // this.canvas.BackColor = System.Drawing.Color.Transparent; this.canvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.canvas.Location = new System.Drawing.Point(11, 67); + this.canvas.Location = new System.Drawing.Point(11, 59); this.canvas.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.canvas.Name = "canvas"; this.canvas.Size = new System.Drawing.Size(900, 500); @@ -128,7 +128,7 @@ this.btnSaveCopy.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnSaveCopy.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnSaveCopy.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); - this.btnSaveCopy.Location = new System.Drawing.Point(401, 166); + this.btnSaveCopy.Location = new System.Drawing.Point(354, 3); this.btnSaveCopy.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.btnSaveCopy.Name = "btnSaveCopy"; this.btnSaveCopy.Size = new System.Drawing.Size(135, 39); @@ -151,10 +151,13 @@ // this.panelFile.BackColor = System.Drawing.Color.Transparent; this.panelFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelFile.Controls.Add(this.btnLoadFile); this.panelFile.Controls.Add(this.tbxProjectName); + this.panelFile.Controls.Add(this.btnSave); + this.panelFile.Controls.Add(this.btnSaveCopy); this.panelFile.Location = new System.Drawing.Point(12, 6); this.panelFile.Name = "panelFile"; - this.panelFile.Size = new System.Drawing.Size(644, 55); + this.panelFile.Size = new System.Drawing.Size(644, 47); this.panelFile.TabIndex = 8; // // btnLoadFile @@ -162,7 +165,7 @@ this.btnLoadFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnLoadFile.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnLoadFile.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); - this.btnLoadFile.Location = new System.Drawing.Point(540, 166); + this.btnLoadFile.Location = new System.Drawing.Point(493, 3); this.btnLoadFile.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); this.btnLoadFile.Name = "btnLoadFile"; this.btnLoadFile.Size = new System.Drawing.Size(143, 39); @@ -392,7 +395,7 @@ this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.panelTools.BackColor = System.Drawing.Color.Transparent; this.panelTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelTools.Controls.Add(this.pictureBox1); + this.panelTools.Controls.Add(this.pbxSample); this.panelTools.Controls.Add(this.btnRandomColor); this.panelTools.Controls.Add(this.btnColorPicker); this.panelTools.Controls.Add(this.btnColorHistory1); @@ -403,16 +406,16 @@ this.panelTools.Controls.Add(this.nupPencilWidth); this.panelTools.Location = new System.Drawing.Point(920, 6); this.panelTools.Name = "panelTools"; - this.panelTools.Size = new System.Drawing.Size(200, 199); + this.panelTools.Size = new System.Drawing.Size(200, 193); this.panelTools.TabIndex = 31; // - // pictureBox1 + // pbxSample // - this.pictureBox1.Location = new System.Drawing.Point(10, 152); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(101, 33); - this.pictureBox1.TabIndex = 35; - this.pictureBox1.TabStop = false; + this.pbxSample.Location = new System.Drawing.Point(10, 152); + this.pbxSample.Name = "pbxSample"; + this.pbxSample.Size = new System.Drawing.Size(101, 33); + this.pbxSample.TabIndex = 35; + this.pbxSample.TabStop = false; // // btnRandomColor // @@ -504,7 +507,7 @@ this.panel2.Controls.Add(this.label1); this.panel2.Controls.Add(this.button2); this.panel2.Controls.Add(this.lsbTools); - this.panel2.Location = new System.Drawing.Point(920, 211); + this.panel2.Location = new System.Drawing.Point(920, 205); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(200, 175); this.panel2.TabIndex = 36; @@ -543,7 +546,7 @@ this.panel3.Controls.Add(this.label2); this.panel3.Controls.Add(this.button1); this.panel3.Controls.Add(this.listBox1); - this.panel3.Location = new System.Drawing.Point(920, 392); + this.panel3.Location = new System.Drawing.Point(920, 384); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(200, 175); this.panel3.TabIndex = 37; @@ -600,11 +603,8 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34))))); this.ClientSize = new System.Drawing.Size(1132, 655); - this.Controls.Add(this.btnLoadFile); this.Controls.Add(this.panel3); - this.Controls.Add(this.btnSaveCopy); this.Controls.Add(this.panel2); - this.Controls.Add(this.btnSave); this.Controls.Add(this.panel1); this.Controls.Add(this.panelHoverColor); this.Controls.Add(this.panelSelectedColor); @@ -632,7 +632,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).EndInit(); this.panelTools.ResumeLayout(false); this.panelTools.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbxSample)).EndInit(); this.panel1.ResumeLayout(false); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); @@ -674,7 +674,7 @@ private System.Windows.Forms.Button btnUndo; private System.Windows.Forms.Button btnRedo; private System.Windows.Forms.Button btnColorPicker; - private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox pbxSample; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Label label1; diff --git a/Paint_2/Form1.cs b/Paint_2/Form1.cs index 88a3c95..03b4713 100644 --- a/Paint_2/Form1.cs +++ b/Paint_2/Form1.cs @@ -117,6 +117,8 @@ namespace Paint_2 lblWidth.Text = "W: " + canvas.Width.ToString(); lblHeight.Text = "H: " + canvas.Height.ToString(); + pbxSample.Image = DrawSample(pbxSample.Size); + if (randomColor) { btnRandomColor.BackColor = FLAT_GREEN; @@ -126,6 +128,15 @@ namespace Paint_2 btnRandomColor.BackColor = FLAT_RED; } } + private Bitmap DrawSample(Size size) + { + Bitmap map = new Bitmap(size.Width,size.Height); + Graphics gr = Graphics.FromImage(map); + + gr.DrawLine(new Pen(sketch.CurrentTool.Color,sketch.CurrentTool.Width),new Point(0,0),new Point(size.Width,size.Height)); + + return map; + } private Color GetHoverColor() { Point cursorLocation = MousePositionToCanvasPosition();