Fixed a bug where clearing was not actually clearing some history

This commit is contained in:
2022-05-31 14:28:01 +02:00
parent a10da16f12
commit 6fe4fe2b83
3 changed files with 40 additions and 47 deletions

View File

@@ -82,6 +82,11 @@ namespace Paint_2
public void Clear()
{
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
}
public void Stop(Point point)
{

View File

@@ -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;

View File

@@ -83,6 +83,11 @@ namespace Paint_2
public void Clear()
{
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
}
public void Stop(Point point)
{