From e0a4a6194cd988ed901ef3c2cd4ad7b47761f636 Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Mon, 2 Jun 2025 13:43:03 +0300 Subject: [PATCH] Removed old history class --- McBitFont/CanvasHistory.cs | 85 -------------------------------------- McBitFont/ChangeHistory.cs | 4 -- 2 files changed, 89 deletions(-) delete mode 100644 McBitFont/CanvasHistory.cs diff --git a/McBitFont/CanvasHistory.cs b/McBitFont/CanvasHistory.cs deleted file mode 100644 index 887d258..0000000 --- a/McBitFont/CanvasHistory.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - - -namespace McBitFont { - internal class CanvasHistory { - private List stack; - public int Depth { get; set; } - public int Index { get; set; } - public int Count { - get { return stack.Count - 1; } - } - public int Redos { - get { - var r = Count - Index - 1; - - return r < 0 ? 0 : r; - } - } - public int Undos { - get { - return Index + 1; - } - } - - - public CanvasHistory(int depth = 50) { - Depth = depth; - Index = -1; - stack = []; - } - - public void Clear() { - stack.Clear(); - Index = -1; - } - - public void AddPre(MainForm.FrameMiniature f, bool useIndex = true) { - if (Count < 0) stack.Add(new bool[f.width, f.height]); - if (Index < Count - 1) { - stack.RemoveRange(Index + 1, Count - Index - 1); - } - bool[,] d = new bool[f.width, f.height]; - Array.Copy(f.data, d, f.data.Length); - stack.Insert(Count, d); - if (useIndex) { - if (Count > Depth) stack.RemoveAt(0); - else Index++; - } - } - - public void AddPost(MainForm.FrameMiniature f) { - var d = stack.ElementAt(Count); - Array.Copy(f.data, d, f.data.Length); - } - - public void ApplyAdded() { - while (Count > Depth) stack.RemoveAt(0); - Index = Count - 1; - } - - public void Remove(bool useIndex = true) { - stack.RemoveAt(Count - 1); - if (useIndex) Index--; - } - - public void Undo(MainForm.FrameMiniature f) { - if (Index < 0) return; - var d = stack.ElementAt(Index); - Array.Copy(d, f.data, d.Length); - Index--; - } - - public void Redo(MainForm.FrameMiniature f) { - if (Index >= Count - 1) return; - Index++; - var d = stack.ElementAt(Index + 1); - Array.Copy(d, f.data, d.Length); - } - } -} diff --git a/McBitFont/ChangeHistory.cs b/McBitFont/ChangeHistory.cs index d96713c..80b3b24 100644 --- a/McBitFont/ChangeHistory.cs +++ b/McBitFont/ChangeHistory.cs @@ -1,10 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using static McBitFont.MainForm;