Removed old history class
This commit is contained in:
@@ -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<bool[,]> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,10 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using static McBitFont.MainForm;
|
using static McBitFont.MainForm;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user