From 6fe4fe2b831c778a28670a66b1b32ea96962eba5 Mon Sep 17 00:00:00 2001 From: maxluli Date: Tue, 31 May 2022 14:28:01 +0200 Subject: [PATCH] Fixed a bug where clearing was not actually clearing some history --- Paint_2/DotPencil.cs | 5 +++ Paint_2/Form1.Designer.cs | 77 +++++++++++++++------------------------ Paint_2/Pencil.cs | 5 +++ 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/Paint_2/DotPencil.cs b/Paint_2/DotPencil.cs index d8354fe..92f6a4b 100644 --- a/Paint_2/DotPencil.cs +++ b/Paint_2/DotPencil.cs @@ -82,6 +82,11 @@ namespace Paint_2 public void Clear() { Drawings = new List>(); + DrawingsRedo = new List>(); + Colors = new List(); + ColorsRedo = new List(); + Widths = new List(); + WidthsRedo = new List(); } public void Stop(Point point) { diff --git a/Paint_2/Form1.Designer.cs b/Paint_2/Form1.Designer.cs index 2cabb6d..44de49f 100644 --- a/Paint_2/Form1.Designer.cs +++ b/Paint_2/Form1.Designer.cs @@ -35,7 +35,6 @@ this.btnSaveCopy = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.lblSelectedColor = new System.Windows.Forms.Label(); - this.btnImportImage = new System.Windows.Forms.Button(); this.panelFile = new System.Windows.Forms.Panel(); this.label10 = new System.Windows.Forms.Label(); this.panelDrawing = new System.Windows.Forms.Panel(); @@ -70,11 +69,11 @@ this.btnSetColor = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.panelTools = new System.Windows.Forms.Panel(); + this.btnRedo = new System.Windows.Forms.Button(); + this.btnUndo = new System.Windows.Forms.Button(); this.btnRandomColor = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.lsbTools = new System.Windows.Forms.ListBox(); - this.btnUndo = new System.Windows.Forms.Button(); - this.btnRedo = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit(); this.panelFile.SuspendLayout(); this.panelDrawing.SuspendLayout(); @@ -157,20 +156,6 @@ this.lblSelectedColor.TabIndex = 1; this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255"; // - // btnImportImage - // - this.btnImportImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnImportImage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); - this.btnImportImage.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.btnImportImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); - this.btnImportImage.Location = new System.Drawing.Point(750, 606); - this.btnImportImage.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); - this.btnImportImage.Name = "btnImportImage"; - this.btnImportImage.Size = new System.Drawing.Size(171, 48); - this.btnImportImage.TabIndex = 6; - this.btnImportImage.Text = "Import Image"; - this.btnImportImage.UseVisualStyleBackColor = false; - // // panelFile // this.panelFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); @@ -603,6 +588,34 @@ this.panelTools.Size = new System.Drawing.Size(163, 593); this.panelTools.TabIndex = 31; // + // btnRedo + // + this.btnRedo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); + this.btnRedo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.btnRedo.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnRedo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); + this.btnRedo.Location = new System.Drawing.Point(85, 547); + this.btnRedo.Name = "btnRedo"; + this.btnRedo.Size = new System.Drawing.Size(75, 43); + this.btnRedo.TabIndex = 36; + this.btnRedo.Text = "Redo"; + this.btnRedo.UseVisualStyleBackColor = false; + this.btnRedo.Click += new System.EventHandler(this.btnRedo_Click); + // + // btnUndo + // + this.btnUndo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); + 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.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.Name = "btnUndo"; + this.btnUndo.Size = new System.Drawing.Size(75, 43); + this.btnUndo.TabIndex = 35; + this.btnUndo.Text = "Undo"; + this.btnUndo.UseVisualStyleBackColor = false; + this.btnUndo.Click += new System.EventHandler(this.btnUndo_Click); + // // btnRandomColor // this.btnRandomColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); @@ -640,34 +653,6 @@ this.lsbTools.TabIndex = 32; this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged); // - // btnUndo - // - this.btnUndo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); - 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.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.Name = "btnUndo"; - this.btnUndo.Size = new System.Drawing.Size(75, 43); - this.btnUndo.TabIndex = 35; - this.btnUndo.Text = "Undo"; - this.btnUndo.UseVisualStyleBackColor = false; - this.btnUndo.Click += new System.EventHandler(this.btnUndo_Click); - // - // btnRedo - // - this.btnRedo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41))))); - this.btnRedo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.btnRedo.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnRedo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); - this.btnRedo.Location = new System.Drawing.Point(85, 547); - this.btnRedo.Name = "btnRedo"; - this.btnRedo.Size = new System.Drawing.Size(75, 43); - this.btnRedo.TabIndex = 36; - this.btnRedo.Text = "Redo"; - this.btnRedo.UseVisualStyleBackColor = false; - this.btnRedo.Click += new System.EventHandler(this.btnRedo_Click); - // // PaintForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F); @@ -680,7 +665,6 @@ this.Controls.Add(this.panelDrawing); this.Controls.Add(this.panelFile); this.Controls.Add(this.btnClear); - this.Controls.Add(this.btnImportImage); this.Controls.Add(this.canvas); 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))))); @@ -716,7 +700,6 @@ private System.Windows.Forms.Button btnSaveCopy; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lblSelectedColor; - private System.Windows.Forms.Button btnImportImage; private System.Windows.Forms.Panel panelFile; private System.Windows.Forms.Label label10; private System.Windows.Forms.Panel panelDrawing; diff --git a/Paint_2/Pencil.cs b/Paint_2/Pencil.cs index a3c7cc1..cca5f63 100644 --- a/Paint_2/Pencil.cs +++ b/Paint_2/Pencil.cs @@ -83,6 +83,11 @@ namespace Paint_2 public void Clear() { Drawings = new List>(); + DrawingsRedo = new List>(); + Colors = new List(); + ColorsRedo = new List(); + Widths = new List(); + WidthsRedo = new List(); } public void Stop(Point point) {