From 1a26a2d16b64c17a0b2a76b84818aa424033ae0a Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Mon, 2 Jun 2025 14:09:06 +0300 Subject: [PATCH] Hotfix: history object creation time --- McBitFont/Form1.cs | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 407f9e7..45fa49a 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -128,6 +128,8 @@ namespace McBitFont { fbuf = new FrameMiniature(0, dotWidth, dotHeight); + history = new(this); + // Chek for arguments if (Environment.GetCommandLineArgs().Length > 1) { LoadProject(Environment.GetCommandLineArgs()[1]); @@ -139,8 +141,7 @@ namespace McBitFont { CodeShiftToolStripMenuItem.Visible = frames.Count > 1; CheckForAdd(); - - history = new(this); + } [DllImport("user32.dll")] @@ -285,9 +286,6 @@ namespace McBitFont { } SetNewWH(); cbZoom_SelectedIndexChanged(cbZoom, null); - - // Re-create history object - //history = new CanvasHistory(); } private void cbZoom_SelectedIndexChanged(object sender, EventArgs e) { @@ -335,7 +333,6 @@ namespace McBitFont { (x, y, x2, y2) = RectSelCoords(); - //history.AddPre(f); for (int i = x; i <= x2; i++) { c = f.data[i, y]; for (int j = y; j <= y2; j++) { @@ -346,7 +343,6 @@ namespace McBitFont { } } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -359,7 +355,6 @@ namespace McBitFont { (x, y, x2, y2) = RectSelCoords(); - //history.AddPre(f); for (int i = x; i <= x2; i++) { c = f.data[i, y2]; for (int j = y2; j >= y; j--) { @@ -370,7 +365,6 @@ namespace McBitFont { } } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -383,7 +377,6 @@ namespace McBitFont { (x, y, x2, y2) = RectSelCoords(); - //history.AddPre(f); for (int j = y; j <= y2; j++) { c = f.data[x, j]; for (int i = x; i <= x2; i++) { @@ -394,7 +387,6 @@ namespace McBitFont { } } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -406,7 +398,6 @@ namespace McBitFont { bool c; (x, y, x2, y2) = RectSelCoords(); - //history.AddPre(f); for (int j = y; j <= y2; j++) { c = f.data[x2, j]; for (int i = x2; i >= x; i--) { @@ -417,7 +408,6 @@ namespace McBitFont { } } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -485,13 +475,8 @@ namespace McBitFont { NormPoints(ref selection1, ref selection2); dotPanel.Invalidate(); } else { - //if (!fChanged) { - // history.Remove(false); - //} else { if (fChanged) { fChanged = false; - //history.ApplyAdded(); - //history.AddPost(f); history.Add(f); } CheckHistoryButtons(); @@ -554,8 +539,6 @@ namespace McBitFont { private void btnInvert_Click(object sender, EventArgs e) { int x, y, x2, y2; - //history.AddPre(f); - (x, y, x2, y2) = RectSelCoords(); for (int i = x; i <= x2; i++) { @@ -564,7 +547,6 @@ namespace McBitFont { } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -577,7 +559,6 @@ namespace McBitFont { (x, y, x2, y2) = RectSelCoords(); - //history.AddPre(f); for (j = y; j <= y2; j++) { a = x; b = x2; @@ -589,7 +570,6 @@ namespace McBitFont { b--; } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -602,7 +582,6 @@ namespace McBitFont { (x, y, x2, y2) = RectSelCoords(); - //history.AddPre(f); for (i = x; i <= x2; i++) { a = y; b = y2; @@ -614,7 +593,6 @@ namespace McBitFont { b--; } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -786,7 +764,6 @@ namespace McBitFont { FrameMiniature newf; if (form.cbSingle.Checked) { frames.Add(new FrameMiniature(0, neww, newh)); - //f = frames.Find(x => x.code == 0); append = "Single"; monospaced = false; } else { @@ -839,8 +816,6 @@ namespace McBitFont { miniList.Refresh(); dotPanel.Refresh(); - // Re-create history object - //history = new CanvasHistory(); history.Clear(); Cursor.Current = Cursors.Default; @@ -861,8 +836,6 @@ namespace McBitFont { return; } dotPanel.SuspendLayout(); - // Clear history - //history.Clear(); var sel = miniList.SelectedItems[0]; int code = Convert.ToInt32(sel.ImageKey); @@ -965,8 +938,6 @@ namespace McBitFont { CheckForAdd(); - // Re-create history object - //history = new CanvasHistory(); history.Clear(); tsmiMakeVarWidth.Visible = monospaced; @@ -1019,7 +990,6 @@ namespace McBitFont { FrameMiniature ff = frames.Find(x => x.code == code); frames.Remove(ff); miniList.SelectedItems[0].Remove(); - //miniList.Items[0].Selected = true; } private void prependSymbolToolStripMenuItem_Click(object sender, EventArgs e) { @@ -1080,7 +1050,6 @@ namespace McBitFont { return; } - //history.AddPre(f); int di, dj, wmax, hmax, selw, selh; if (chkRectSelect.Checked) { di = selection1.X; @@ -1102,7 +1071,6 @@ namespace McBitFont { } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); dotPanel.Refresh(); @@ -1152,8 +1120,6 @@ namespace McBitFont { private void FillFrame(bool val) { int x, y, x2, y2; - //history.AddPre(f); - (x, y, x2, y2) = RectSelCoords(); for (int i = x; i <= x2; i++) { @@ -1162,7 +1128,6 @@ namespace McBitFont { } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); SetModified(); @@ -1244,14 +1209,12 @@ namespace McBitFont { } private void undoToolStripMenuItem_Click(object sender, EventArgs e) { - //history.Undo(f); history.Undo(); dotPanel.Refresh(); CheckHistoryButtons(); } private void redoToolStripMenuItem_Click(object sender, EventArgs e) { - //history.Redo(f); history.Redo(); dotPanel.Refresh(); CheckHistoryButtons(); @@ -1303,13 +1266,11 @@ namespace McBitFont { private void importImageToolStripMenuItem_Click(object sender, EventArgs e) { ImageImporter iform = new ImageImporter(f.width, f.height); if (iform.ShowDialog() == DialogResult.OK) { - //history.AddPre(f); for (int i = 0; i < iform.bmpScaled.Width; i++) { for (int j = 0; j < iform.bmpScaled.Height; j++) { f.data[i, j] = iform.bmpScaled.GetPixel(i, j).ToArgb().Equals(Color.Black.ToArgb()); } } - //history.AddPost(f); history.Add(f); CheckHistoryButtons(); dotPanel.Refresh();