WIP: working on new history class
This commit is contained in:
@@ -2,31 +2,66 @@
|
|||||||
using System.Collections;
|
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.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
using static McBitFont.ChangeHistory;
|
using static McBitFont.ChangeHistory;
|
||||||
using static McBitFont.MainForm;
|
using static McBitFont.MainForm;
|
||||||
|
|
||||||
namespace McBitFont {
|
namespace McBitFont {
|
||||||
internal class ChangeHistory(int depth = 50) {
|
internal class ChangeHistory {
|
||||||
private List<ChangeEvent> timeline = [];
|
private MainForm mainForm;
|
||||||
|
private List<ChangeType> timeline = [];
|
||||||
private List<FrameMiniature> canvasChanges = [];
|
private List<FrameMiniature> canvasChanges = [];
|
||||||
private List<List<FrameMiniature>> fontChanges = [];
|
private List<List<FrameMiniature>> fontChanges = [];
|
||||||
public int Depth { get; set; } = depth;
|
private List<int> selFrameChanges = [];
|
||||||
|
private int canvasIndex = 0;
|
||||||
|
private int fontIndex = 0;
|
||||||
|
private int selFrameIndex = 0;
|
||||||
|
public int Depth { get; set; }
|
||||||
public int Index { get; set; } = -1;
|
public int Index { get; set; } = -1;
|
||||||
public int Count {
|
public int Count {
|
||||||
get { return timeline.Count; }
|
get { return timeline.Count; }
|
||||||
}
|
}
|
||||||
|
public int Undos {
|
||||||
|
get { return Index < 0 ? 0 : Index + 1; }
|
||||||
|
}
|
||||||
|
public int Redos {
|
||||||
|
get { return Index < 0 ? Count : Count - Index - 1; }
|
||||||
|
}
|
||||||
|
public bool HistoryAction { get; set; } = false;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public ChangeHistory(MainForm form, int depth = 100) {
|
||||||
|
timeline = [];
|
||||||
|
canvasChanges = [];
|
||||||
|
fontChanges = [];
|
||||||
|
selFrameChanges = [];
|
||||||
|
mainForm = form;
|
||||||
|
Depth = depth;
|
||||||
|
ResetIndices();
|
||||||
|
Add();
|
||||||
|
HistoryAction = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetIndices() {
|
||||||
|
Index = -1;
|
||||||
|
canvasIndex = 0;
|
||||||
|
fontIndex = 0;
|
||||||
|
selFrameIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public enum ChangeType {
|
public enum ChangeType {
|
||||||
None = 0,
|
None = 0,
|
||||||
Canvas = 1, // Changes made to canvas
|
Canvas = 1, // Changes made to canvas
|
||||||
Font = 2 // Symbol width has been changed
|
Font = 2, // Symbol width has been changed
|
||||||
}
|
Frame = 3 // Selected another frame
|
||||||
public class ChangeEvent(ChangeType type, int index) {
|
|
||||||
public ChangeType Type { get; set; } = type;
|
|
||||||
public int Index { get; set; } = index;
|
|
||||||
}
|
}
|
||||||
|
//public class ChangeEvent(ChangeType type, int index) {
|
||||||
|
// public ChangeType Type { get; set; } = type;
|
||||||
|
// public int Index { get; set; } = index;
|
||||||
|
//}
|
||||||
|
|
||||||
private static FrameMiniature CopyFrameSimple(FrameMiniature f) {
|
private static FrameMiniature CopyFrameSimple(FrameMiniature f) {
|
||||||
FrameMiniature newf = new(f.code, f.width, f.height);
|
FrameMiniature newf = new(f.code, f.width, f.height);
|
||||||
@@ -38,77 +73,191 @@ namespace McBitFont {
|
|||||||
timeline.Clear();
|
timeline.Clear();
|
||||||
canvasChanges.Clear();
|
canvasChanges.Clear();
|
||||||
fontChanges.Clear();
|
fontChanges.Clear();
|
||||||
Index = -1;
|
selFrameChanges.Clear();
|
||||||
|
ResetIndices();
|
||||||
|
Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove oldest event and recalculate indices
|
// Remove from a proper list by change type
|
||||||
private bool RemoveOldest() {
|
private bool RemoveByType(ChangeType ct, bool first = true) {
|
||||||
if (Count == 0) return false;
|
|
||||||
ChangeType ct = timeline.First().Type;
|
|
||||||
|
|
||||||
switch (ct) {
|
switch (ct) {
|
||||||
case ChangeType.Canvas:
|
case ChangeType.Canvas:
|
||||||
if (canvasChanges.Count == 0) return false;
|
if (canvasChanges.Count <= 1) return false;
|
||||||
canvasChanges.RemoveAt(0);
|
if ((first && canvasIndex > 0) || (!first && canvasIndex == canvasChanges.Count - 1)) canvasIndex--;
|
||||||
|
canvasChanges.RemoveAt(first ? 0 : canvasChanges.Count - 1);
|
||||||
break;
|
break;
|
||||||
case ChangeType.Font:
|
case ChangeType.Font:
|
||||||
if (fontChanges.Count == 0) return false;
|
if (fontChanges.Count <= 1) return false;
|
||||||
fontChanges.RemoveAt(0);
|
if ((first && fontIndex > 0) || (!first && fontIndex == fontChanges.Count - 1)) fontIndex--;
|
||||||
|
fontChanges.RemoveAt(first ? 0 : fontChanges.Count - 1);
|
||||||
|
break;
|
||||||
|
case ChangeType.Frame:
|
||||||
|
if (selFrameChanges.Count <= 1) return false;
|
||||||
|
if ((first && selFrameIndex > 0) || (!first && selFrameIndex == selFrameChanges.Count - 1)) selFrameIndex--;
|
||||||
|
selFrameChanges.RemoveAt(first ? 0 : selFrameChanges.Count - 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
timeline.RemoveAt(0);
|
if ((first && Index > 0) || (!first && Index == Count - 1) || Count == 1) Index--;
|
||||||
for (int i = 0; i < Count; i++) {
|
timeline.RemoveAt(first ? 0 : Count - 1);
|
||||||
if (timeline[i].Type == ct) timeline[i].Index--;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(bool useIndex = true) {
|
// Remove oldest event
|
||||||
if (Index == -1) return false;
|
private bool RemoveOldest() {
|
||||||
var ce = timeline.Last();
|
if (Count == 0) return false;
|
||||||
switch (ce.Type) {
|
ChangeType ct = timeline.First();
|
||||||
case ChangeType.Canvas:
|
RemoveByType(ct);
|
||||||
canvasChanges.RemoveAt(ce.Index);
|
|
||||||
break;
|
return true;
|
||||||
case ChangeType.Font:
|
|
||||||
fontChanges.RemoveAt(ce.Index);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
timeline.Remove(ce);
|
|
||||||
if (useIndex) Index--;
|
// Remove last event
|
||||||
|
public bool RemoveLast() {
|
||||||
|
if (Count == 0) return false;
|
||||||
|
var ct = timeline.Last();
|
||||||
|
RemoveByType(ct, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove history tail
|
// Remove history tail
|
||||||
private void TruncateTail() {
|
private void TruncateTail() {
|
||||||
// Check if the Index does not point to the last event
|
// Check if the Index does not point to the last event
|
||||||
if (Index >= 0 && Index < Count - 1) {
|
//while (Index < Count - 1) Remove
|
||||||
timeline.RemoveRange(Index + 1, Count - Index - 1);
|
if (Index >= -1 && Index < Count - 1) {
|
||||||
|
timeline.RemoveRange( Index + 1, Count - Index - 1);
|
||||||
|
canvasChanges.RemoveRange( canvasIndex + 1, canvasChanges.Count - canvasIndex - 1);
|
||||||
|
fontChanges.RemoveRange( fontIndex + 1, fontChanges.Count - fontIndex - 1);
|
||||||
|
selFrameChanges.RemoveRange(selFrameIndex + 1, selFrameChanges.Count - selFrameIndex - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks and resets HistoryAction property to abort Add action
|
||||||
|
private bool CheckHistoryAction() {
|
||||||
|
if (HistoryAction) {
|
||||||
|
HistoryAction = false;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add first states to all lists
|
||||||
|
private void Add() {
|
||||||
|
Add(mainForm.f, false);
|
||||||
|
Add(mainForm.frames, false);
|
||||||
|
var fff = mainForm.f; // Marshal-by-reference warning workaround
|
||||||
|
int ccс = fff.code; //
|
||||||
|
Add(ccс, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Add canvas change
|
// Add canvas change
|
||||||
public void Add(FrameMiniature f) {
|
public void Add(FrameMiniature f, bool useIndex = true) {
|
||||||
|
if (useIndex && CheckHistoryAction()) return;
|
||||||
TruncateTail();
|
TruncateTail();
|
||||||
|
|
||||||
canvasChanges.Add(CopyFrameSimple(f));
|
|
||||||
timeline.Add(new ChangeEvent(ChangeType.Canvas, canvasChanges.Count - 1));
|
|
||||||
if (Count > Depth) RemoveOldest();
|
if (Count > Depth) RemoveOldest();
|
||||||
else Index++;
|
canvasChanges.Add(CopyFrameSimple(f));
|
||||||
|
if (useIndex) {
|
||||||
|
timeline.Add(ChangeType.Canvas);
|
||||||
|
Index++;
|
||||||
|
canvasIndex++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Font change
|
// Add Font change
|
||||||
public void Add(List<FrameMiniature> ff) {
|
public void Add(List<FrameMiniature> ff, bool useIndex = true) {
|
||||||
//TruncateTail();
|
if (useIndex && CheckHistoryAction()) return;
|
||||||
|
TruncateTail();
|
||||||
|
|
||||||
//fontChanges.Add(CopyFrameSimple(f));
|
var l = new List<FrameMiniature>();
|
||||||
//timeline.Add(new ChangeEvent(ChangeType.Canvas, canvasChanges.Count - 1));
|
foreach (var f in ff) {
|
||||||
//if (Count > Depth) RemoveOldest();
|
l.Add(CopyFrameSimple(f));
|
||||||
//else Index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Count > Depth) RemoveOldest();
|
||||||
|
fontChanges.Add(l);
|
||||||
|
if (useIndex) {
|
||||||
|
timeline.Add(ChangeType.Font);
|
||||||
|
Index++;
|
||||||
|
fontIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Frame selection change
|
||||||
|
public void Add(int code, bool useIndex = true) {
|
||||||
|
if (useIndex && CheckHistoryAction()) return;
|
||||||
|
if (useIndex) {
|
||||||
|
Add(mainForm.frames.Find(x => x.code == code));
|
||||||
|
//Add(mainForm.f);
|
||||||
|
}
|
||||||
|
TruncateTail();
|
||||||
|
|
||||||
|
if (Count > Depth) RemoveOldest();
|
||||||
|
selFrameChanges.Add(code);
|
||||||
|
if (useIndex) {
|
||||||
|
timeline.Add(ChangeType.Frame);
|
||||||
|
Index++;
|
||||||
|
selFrameIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Do(bool undo = true) {
|
||||||
|
ChangeType ct = timeline.ElementAt(Index + (undo ? 0 : 1));
|
||||||
|
int dIndex = undo ? -1 : 1;
|
||||||
|
switch (ct) {
|
||||||
|
case ChangeType.Canvas:
|
||||||
|
canvasIndex += dIndex;
|
||||||
|
mainForm.f = CopyFrameSimple(canvasChanges[canvasIndex]);
|
||||||
|
break;
|
||||||
|
case ChangeType.Font:
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
fontIndex += dIndex;
|
||||||
|
mainForm.frames.Clear();
|
||||||
|
mainForm.miniList.Clear();
|
||||||
|
mainForm.ilMiniatures.Images.Clear();
|
||||||
|
foreach (var f in fontChanges[fontIndex]) {
|
||||||
|
mainForm.frames.Add(CopyFrameSimple(f));
|
||||||
|
}
|
||||||
|
mainForm.FillFrameLists();
|
||||||
|
Cursor.Current = Cursors.Default;
|
||||||
|
break;
|
||||||
|
case ChangeType.Frame:
|
||||||
|
HistoryAction = true;
|
||||||
|
selFrameIndex += dIndex;
|
||||||
|
var s = selFrameChanges[selFrameIndex].ToString().PadLeft(3, '0');
|
||||||
|
var sel = mainForm.miniList.Items.Find(s, false);
|
||||||
|
if (sel.Length > 0) sel[0].Selected = true;
|
||||||
|
//if (undo) Undo(); else Redo();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Index += dIndex;
|
||||||
|
if (ct == ChangeType.Frame)
|
||||||
|
if (undo) Undo(); else Redo();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Undo last change
|
||||||
|
public bool Undo() {
|
||||||
|
if (Undos < 1) return false;
|
||||||
|
Do();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redo last ondone change
|
||||||
|
public bool Redo() {
|
||||||
|
if (Redos < 1) return false;
|
||||||
|
Do(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
McBitFont/Form1.Designer.cs
generated
20
McBitFont/Form1.Designer.cs
generated
@@ -370,7 +370,7 @@
|
|||||||
btnExport.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
btnExport.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||||
toolTip1.SetToolTip(btnExport, "Configure and export data");
|
toolTip1.SetToolTip(btnExport, "Configure and export data");
|
||||||
btnExport.UseVisualStyleBackColor = true;
|
btnExport.UseVisualStyleBackColor = true;
|
||||||
btnExport.Click += button1_Click;
|
btnExport.Click += Export_Click;
|
||||||
//
|
//
|
||||||
// miniList
|
// miniList
|
||||||
//
|
//
|
||||||
@@ -614,7 +614,7 @@
|
|||||||
exportToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
|
exportToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
|
||||||
exportToolStripMenuItem.Text = "Export";
|
exportToolStripMenuItem.Text = "Export";
|
||||||
exportToolStripMenuItem.ToolTipText = "Configure and export data";
|
exportToolStripMenuItem.ToolTipText = "Configure and export data";
|
||||||
exportToolStripMenuItem.Click += button1_Click;
|
exportToolStripMenuItem.Click += Export_Click;
|
||||||
//
|
//
|
||||||
// exportFontLayoutPNGToolStripMenuItem
|
// exportFontLayoutPNGToolStripMenuItem
|
||||||
//
|
//
|
||||||
@@ -654,7 +654,7 @@
|
|||||||
undoToolStripMenuItem.Image = Properties.Resources.arrow_undo;
|
undoToolStripMenuItem.Image = Properties.Resources.arrow_undo;
|
||||||
undoToolStripMenuItem.Name = "undoToolStripMenuItem";
|
undoToolStripMenuItem.Name = "undoToolStripMenuItem";
|
||||||
undoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z;
|
undoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z;
|
||||||
undoToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
undoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||||
undoToolStripMenuItem.Text = "Undo";
|
undoToolStripMenuItem.Text = "Undo";
|
||||||
undoToolStripMenuItem.ToolTipText = "Undo last canvas change";
|
undoToolStripMenuItem.ToolTipText = "Undo last canvas change";
|
||||||
undoToolStripMenuItem.Click += undoToolStripMenuItem_Click;
|
undoToolStripMenuItem.Click += undoToolStripMenuItem_Click;
|
||||||
@@ -664,7 +664,7 @@
|
|||||||
redoToolStripMenuItem.Image = Properties.Resources.arrow_redo;
|
redoToolStripMenuItem.Image = Properties.Resources.arrow_redo;
|
||||||
redoToolStripMenuItem.Name = "redoToolStripMenuItem";
|
redoToolStripMenuItem.Name = "redoToolStripMenuItem";
|
||||||
redoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y;
|
redoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y;
|
||||||
redoToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
redoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||||
redoToolStripMenuItem.Text = "Redo";
|
redoToolStripMenuItem.Text = "Redo";
|
||||||
redoToolStripMenuItem.ToolTipText = "Redo canvas change";
|
redoToolStripMenuItem.ToolTipText = "Redo canvas change";
|
||||||
redoToolStripMenuItem.Click += redoToolStripMenuItem_Click;
|
redoToolStripMenuItem.Click += redoToolStripMenuItem_Click;
|
||||||
@@ -675,7 +675,7 @@
|
|||||||
copyToolStripMenuItem.Name = "copyToolStripMenuItem";
|
copyToolStripMenuItem.Name = "copyToolStripMenuItem";
|
||||||
copyToolStripMenuItem.ShortcutKeyDisplayString = "";
|
copyToolStripMenuItem.ShortcutKeyDisplayString = "";
|
||||||
copyToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C;
|
copyToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C;
|
||||||
copyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
copyToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||||
copyToolStripMenuItem.Text = "Copy";
|
copyToolStripMenuItem.Text = "Copy";
|
||||||
copyToolStripMenuItem.ToolTipText = "Copy current symbol to clipboard";
|
copyToolStripMenuItem.ToolTipText = "Copy current symbol to clipboard";
|
||||||
copyToolStripMenuItem.Click += copyToolStripMenuItem_Click;
|
copyToolStripMenuItem.Click += copyToolStripMenuItem_Click;
|
||||||
@@ -686,7 +686,7 @@
|
|||||||
pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
|
pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
|
||||||
pasteToolStripMenuItem.ShortcutKeyDisplayString = "";
|
pasteToolStripMenuItem.ShortcutKeyDisplayString = "";
|
||||||
pasteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V;
|
pasteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V;
|
||||||
pasteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
pasteToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||||
pasteToolStripMenuItem.Text = "Paste";
|
pasteToolStripMenuItem.Text = "Paste";
|
||||||
pasteToolStripMenuItem.ToolTipText = "Paste from clipboard to current symbol";
|
pasteToolStripMenuItem.ToolTipText = "Paste from clipboard to current symbol";
|
||||||
pasteToolStripMenuItem.Click += pasteToolStripMenuItem_Click;
|
pasteToolStripMenuItem.Click += pasteToolStripMenuItem_Click;
|
||||||
@@ -696,7 +696,7 @@
|
|||||||
selectToolStripMenuItem.Image = Properties.Resources.fam_rectt;
|
selectToolStripMenuItem.Image = Properties.Resources.fam_rectt;
|
||||||
selectToolStripMenuItem.Name = "selectToolStripMenuItem";
|
selectToolStripMenuItem.Name = "selectToolStripMenuItem";
|
||||||
selectToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R;
|
selectToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R;
|
||||||
selectToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
selectToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||||
selectToolStripMenuItem.Text = "Select";
|
selectToolStripMenuItem.Text = "Select";
|
||||||
selectToolStripMenuItem.ToolTipText = "Toggle Rectangle selection tool";
|
selectToolStripMenuItem.ToolTipText = "Toggle Rectangle selection tool";
|
||||||
selectToolStripMenuItem.Click += selectToolStripMenuItem_Click;
|
selectToolStripMenuItem.Click += selectToolStripMenuItem_Click;
|
||||||
@@ -707,7 +707,7 @@
|
|||||||
selectAllToolStripMenuItem.Image = Properties.Resources.arrow_out;
|
selectAllToolStripMenuItem.Image = Properties.Resources.arrow_out;
|
||||||
selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
|
selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
|
||||||
selectAllToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A;
|
selectAllToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A;
|
||||||
selectAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
selectAllToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||||
selectAllToolStripMenuItem.Text = "Select All";
|
selectAllToolStripMenuItem.Text = "Select All";
|
||||||
selectAllToolStripMenuItem.ToolTipText = "Select entire canvas";
|
selectAllToolStripMenuItem.ToolTipText = "Select entire canvas";
|
||||||
selectAllToolStripMenuItem.Click += selectAllToolStripMenuItem_Click;
|
selectAllToolStripMenuItem.Click += selectAllToolStripMenuItem_Click;
|
||||||
@@ -1138,8 +1138,6 @@
|
|||||||
private System.Windows.Forms.Button btnMirrorX;
|
private System.Windows.Forms.Button btnMirrorX;
|
||||||
private System.Windows.Forms.Button btnMirrorY;
|
private System.Windows.Forms.Button btnMirrorY;
|
||||||
private System.Windows.Forms.Button btnExport;
|
private System.Windows.Forms.Button btnExport;
|
||||||
private System.Windows.Forms.ListView miniList;
|
|
||||||
private System.Windows.Forms.ImageList ilMiniatures;
|
|
||||||
private System.Windows.Forms.Button btnApply;
|
private System.Windows.Forms.Button btnApply;
|
||||||
private System.Windows.Forms.HScrollBar hScroll;
|
private System.Windows.Forms.HScrollBar hScroll;
|
||||||
private System.Windows.Forms.VScrollBar vScroll;
|
private System.Windows.Forms.VScrollBar vScroll;
|
||||||
@@ -1209,6 +1207,8 @@
|
|||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||||
|
public System.Windows.Forms.ListView miniList;
|
||||||
|
public System.Windows.Forms.ImageList ilMiniatures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
|
||||||
@@ -48,9 +47,10 @@ namespace McBitFont {
|
|||||||
public List<FrameMiniature> frames;
|
public List<FrameMiniature> frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FrameMiniature f;
|
public FrameMiniature f;
|
||||||
public List<FrameMiniature> frames = new List<FrameMiniature>();
|
public List<FrameMiniature> frames = new List<FrameMiniature>();
|
||||||
private CanvasHistory history = new();
|
//private CanvasHistory history = new();
|
||||||
|
private ChangeHistory history;
|
||||||
private int cellSize = 10;
|
private int cellSize = 10;
|
||||||
public int dotWidth, dotHeight;
|
public int dotWidth, dotHeight;
|
||||||
private readonly int pixelOffset = 5;
|
private readonly int pixelOffset = 5;
|
||||||
@@ -139,6 +139,8 @@ namespace McBitFont {
|
|||||||
CodeShiftToolStripMenuItem.Visible = frames.Count > 1;
|
CodeShiftToolStripMenuItem.Visible = frames.Count > 1;
|
||||||
|
|
||||||
CheckForAdd();
|
CheckForAdd();
|
||||||
|
|
||||||
|
history = new(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
@@ -281,7 +283,7 @@ namespace McBitFont {
|
|||||||
cbZoom_SelectedIndexChanged(cbZoom, null);
|
cbZoom_SelectedIndexChanged(cbZoom, null);
|
||||||
|
|
||||||
// Re-create history object
|
// Re-create history object
|
||||||
history = new CanvasHistory();
|
//history = new CanvasHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cbZoom_SelectedIndexChanged(object sender, EventArgs e) {
|
private void cbZoom_SelectedIndexChanged(object sender, EventArgs e) {
|
||||||
@@ -329,7 +331,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (int i = x; i <= x2; i++) {
|
for (int i = x; i <= x2; i++) {
|
||||||
c = f.data[i, y];
|
c = f.data[i, y];
|
||||||
for (int j = y; j <= y2; j++) {
|
for (int j = y; j <= y2; j++) {
|
||||||
@@ -340,7 +342,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -352,7 +355,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (int i = x; i <= x2; i++) {
|
for (int i = x; i <= x2; i++) {
|
||||||
c = f.data[i, y2];
|
c = f.data[i, y2];
|
||||||
for (int j = y2; j >= y; j--) {
|
for (int j = y2; j >= y; j--) {
|
||||||
@@ -363,7 +366,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -375,7 +379,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (int j = y; j <= y2; j++) {
|
for (int j = y; j <= y2; j++) {
|
||||||
c = f.data[x, j];
|
c = f.data[x, j];
|
||||||
for (int i = x; i <= x2; i++) {
|
for (int i = x; i <= x2; i++) {
|
||||||
@@ -386,7 +390,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -397,7 +402,7 @@ namespace McBitFont {
|
|||||||
bool c;
|
bool c;
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (int j = y; j <= y2; j++) {
|
for (int j = y; j <= y2; j++) {
|
||||||
c = f.data[x2, j];
|
c = f.data[x2, j];
|
||||||
for (int i = x2; i >= x; i--) {
|
for (int i = x2; i >= x; i--) {
|
||||||
@@ -408,7 +413,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -458,6 +464,7 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.Button != MouseButtons.None && !mouseDown) {
|
if (e.Button != MouseButtons.None && !mouseDown) {
|
||||||
|
// Started to move a mouse with button held
|
||||||
mouseDown = true;
|
mouseDown = true;
|
||||||
if (rectSel) {
|
if (rectSel) {
|
||||||
selection1.X = i;
|
selection1.X = i;
|
||||||
@@ -465,20 +472,23 @@ namespace McBitFont {
|
|||||||
selection2.X = i;
|
selection2.X = i;
|
||||||
selection2.Y = j;
|
selection2.Y = j;
|
||||||
dotPanel.Invalidate();
|
dotPanel.Invalidate();
|
||||||
} else history.AddPre(f, false);
|
} //else history.AddPre(f, false);
|
||||||
}
|
}
|
||||||
if (e.Button == MouseButtons.None && mouseDown) {
|
if (e.Button == MouseButtons.None && mouseDown) {
|
||||||
|
// Released a mouse button
|
||||||
mouseDown = false;
|
mouseDown = false;
|
||||||
if (rectSel) {
|
if (rectSel) {
|
||||||
NormPoints(ref selection1, ref selection2);
|
NormPoints(ref selection1, ref selection2);
|
||||||
dotPanel.Invalidate();
|
dotPanel.Invalidate();
|
||||||
} else {
|
} else {
|
||||||
if (!fChanged) {
|
//if (!fChanged) {
|
||||||
history.Remove(false);
|
// history.Remove(false);
|
||||||
} else {
|
//} else {
|
||||||
|
if (fChanged) {
|
||||||
fChanged = false;
|
fChanged = false;
|
||||||
history.ApplyAdded();
|
//history.ApplyAdded();
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
}
|
}
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
}
|
}
|
||||||
@@ -540,7 +550,7 @@ namespace McBitFont {
|
|||||||
private void btnInvert_Click(object sender, EventArgs e) {
|
private void btnInvert_Click(object sender, EventArgs e) {
|
||||||
int x, y, x2, y2;
|
int x, y, x2, y2;
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
@@ -550,7 +560,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -562,7 +573,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (j = y; j <= y2; j++) {
|
for (j = y; j <= y2; j++) {
|
||||||
a = x;
|
a = x;
|
||||||
b = x2;
|
b = x2;
|
||||||
@@ -574,7 +585,8 @@ namespace McBitFont {
|
|||||||
b--;
|
b--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -586,7 +598,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (i = x; i <= x2; i++) {
|
for (i = x; i <= x2; i++) {
|
||||||
a = y;
|
a = y;
|
||||||
b = y2;
|
b = y2;
|
||||||
@@ -598,13 +610,14 @@ namespace McBitFont {
|
|||||||
b--;
|
b--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e) {
|
private void Export_Click(object sender, EventArgs e) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
||||||
SaveFrame();
|
SaveFrame();
|
||||||
@@ -636,7 +649,7 @@ namespace McBitFont {
|
|||||||
SetModified(true, true);
|
SetModified(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Bitmap GetMiniPictue(FrameMiniature m) {
|
public static Bitmap GetMiniPictue(FrameMiniature m) {
|
||||||
int picSize = (m.width > m.height) ? m.width : m.height;
|
int picSize = (m.width > m.height) ? m.width : m.height;
|
||||||
var bmp = new Bitmap(picSize, picSize);
|
var bmp = new Bitmap(picSize, picSize);
|
||||||
int imin = m.width < picSize ? (picSize - m.width) / 2 : 0;
|
int imin = m.width < picSize ? (picSize - m.width) / 2 : 0;
|
||||||
@@ -648,7 +661,7 @@ namespace McBitFont {
|
|||||||
bmp.SetPixel(i + imin, j + jmin, c);
|
bmp.SetPixel(i + imin, j + jmin, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bitmap sbmp = new Bitmap(50, 50);
|
Bitmap sbmp = new(50, 50);
|
||||||
using (Graphics g = Graphics.FromImage(sbmp)) {
|
using (Graphics g = Graphics.FromImage(sbmp)) {
|
||||||
g.InterpolationMode = InterpolationMode.NearestNeighbor;
|
g.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||||
@@ -823,7 +836,8 @@ namespace McBitFont {
|
|||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
|
|
||||||
// Re-create history object
|
// Re-create history object
|
||||||
history = new CanvasHistory();
|
//history = new CanvasHistory();
|
||||||
|
history.Clear();
|
||||||
|
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
}
|
}
|
||||||
@@ -842,9 +856,9 @@ namespace McBitFont {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dotPanel.SuspendLayout();
|
||||||
// Clear history
|
// Clear history
|
||||||
history.Clear();
|
//history.Clear();
|
||||||
|
|
||||||
var sel = miniList.SelectedItems[0];
|
var sel = miniList.SelectedItems[0];
|
||||||
int code = Convert.ToInt32(sel.ImageKey);
|
int code = Convert.ToInt32(sel.ImageKey);
|
||||||
@@ -852,7 +866,10 @@ namespace McBitFont {
|
|||||||
nudX.Value = ff.width;
|
nudX.Value = ff.width;
|
||||||
nudY.Value = ff.height;
|
nudY.Value = ff.height;
|
||||||
f = ff;
|
f = ff;
|
||||||
dotPanel.Refresh();
|
|
||||||
|
|
||||||
|
history.Add(code);
|
||||||
|
|
||||||
ff = frames.Find(x => x.code == code);
|
ff = frames.Find(x => x.code == code);
|
||||||
if (frames.Count > 1 && (ff.Equals(frames.First()) || ff.Equals(frames.Last()))) {
|
if (frames.Count > 1 && (ff.Equals(frames.First()) || ff.Equals(frames.Last()))) {
|
||||||
removeSymbolToolStripMenuItem.Enabled = true;
|
removeSymbolToolStripMenuItem.Enabled = true;
|
||||||
@@ -862,6 +879,9 @@ namespace McBitFont {
|
|||||||
tsmiRemoveSymbol.Enabled = false;
|
tsmiRemoveSymbol.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dotPanel.ResumeLayout();
|
||||||
|
dotPanel.Refresh();
|
||||||
|
|
||||||
if (frames.Count > 1 && ff.Equals(frames.First())) {
|
if (frames.Count > 1 && ff.Equals(frames.First())) {
|
||||||
removeBeforeToolStripMenuItem.Enabled = false;
|
removeBeforeToolStripMenuItem.Enabled = false;
|
||||||
removeAfterToolStripMenuItem.Enabled = true;
|
removeAfterToolStripMenuItem.Enabled = true;
|
||||||
@@ -888,6 +908,16 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void FillFrameLists() {
|
||||||
|
foreach (FrameMiniature f in frames) {
|
||||||
|
var s = f.code.ToString().PadLeft(3, '0');
|
||||||
|
var sHex = 'x' + Convert.ToString(f.code, 16).PadLeft(2, '0').ToUpper();
|
||||||
|
var sss = DecodeSymbol(f.code);
|
||||||
|
ilMiniatures.Images.Add(s, (Image)GetMiniPictue(f));
|
||||||
|
miniList.Items.Add(s, (chkHexCodes.Checked ? sHex : s) + ' ' + sss, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadProject(string filename) {
|
private void LoadProject(string filename) {
|
||||||
SaveBlock sav;
|
SaveBlock sav;
|
||||||
|
|
||||||
@@ -905,13 +935,7 @@ namespace McBitFont {
|
|||||||
tsmiMakeVarWidth.Visible = monospaced;
|
tsmiMakeVarWidth.Visible = monospaced;
|
||||||
miniList.Items.Clear();
|
miniList.Items.Clear();
|
||||||
ilMiniatures.Images.Clear();
|
ilMiniatures.Images.Clear();
|
||||||
foreach (FrameMiniature ff in frames) {
|
FillFrameLists();
|
||||||
var s = ff.code.ToString().PadLeft(3, '0');
|
|
||||||
var sHex = 'x' + Convert.ToString(ff.code, 16).PadLeft(2, '0').ToUpper();
|
|
||||||
var sss = DecodeSymbol(ff.code);
|
|
||||||
ilMiniatures.Images.Add(s, (Image)GetMiniPictue(ff));
|
|
||||||
miniList.Items.Add(s, (chkHexCodes.Checked ? sHex : s) + ' ' + sss, s);
|
|
||||||
}
|
|
||||||
nudX.ValueChanged -= nudX_ValueChanged;
|
nudX.ValueChanged -= nudX_ValueChanged;
|
||||||
nudY.ValueChanged -= nudY_ValueChanged;
|
nudY.ValueChanged -= nudY_ValueChanged;
|
||||||
nudX.Value = frames.First().width;
|
nudX.Value = frames.First().width;
|
||||||
@@ -938,7 +962,8 @@ namespace McBitFont {
|
|||||||
CheckForAdd();
|
CheckForAdd();
|
||||||
|
|
||||||
// Re-create history object
|
// Re-create history object
|
||||||
history = new CanvasHistory();
|
//history = new CanvasHistory();
|
||||||
|
history.Clear();
|
||||||
|
|
||||||
tsmiMakeVarWidth.Visible = monospaced;
|
tsmiMakeVarWidth.Visible = monospaced;
|
||||||
makeVarWidthToolStripMenuItem.Visible = monospaced;
|
makeVarWidthToolStripMenuItem.Visible = monospaced;
|
||||||
@@ -1051,7 +1076,7 @@ namespace McBitFont {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
int di, dj, wmax, hmax, selw, selh;
|
int di, dj, wmax, hmax, selw, selh;
|
||||||
if (chkRectSelect.Checked) {
|
if (chkRectSelect.Checked) {
|
||||||
di = selection1.X;
|
di = selection1.X;
|
||||||
@@ -1073,7 +1098,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
SetModified();
|
SetModified();
|
||||||
@@ -1122,7 +1148,7 @@ namespace McBitFont {
|
|||||||
private void FillFrame(bool val) {
|
private void FillFrame(bool val) {
|
||||||
int x, y, x2, y2;
|
int x, y, x2, y2;
|
||||||
|
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
|
|
||||||
(x, y, x2, y2) = RectSelCoords();
|
(x, y, x2, y2) = RectSelCoords();
|
||||||
|
|
||||||
@@ -1132,7 +1158,8 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
SetModified();
|
SetModified();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
@@ -1213,13 +1240,15 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void undoToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void undoToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
history.Undo(f);
|
//history.Undo(f);
|
||||||
|
history.Undo();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redoToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void redoToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
history.Redo(f);
|
//history.Redo(f);
|
||||||
|
history.Redo();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
}
|
}
|
||||||
@@ -1270,13 +1299,14 @@ namespace McBitFont {
|
|||||||
private void importImageToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void importImageToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
ImageImporter iform = new ImageImporter(f.width, f.height);
|
ImageImporter iform = new ImageImporter(f.width, f.height);
|
||||||
if (iform.ShowDialog() == DialogResult.OK) {
|
if (iform.ShowDialog() == DialogResult.OK) {
|
||||||
history.AddPre(f);
|
//history.AddPre(f);
|
||||||
for (int i = 0; i < iform.bmpScaled.Width; i++) {
|
for (int i = 0; i < iform.bmpScaled.Width; i++) {
|
||||||
for (int j = 0; j < iform.bmpScaled.Height; j++) {
|
for (int j = 0; j < iform.bmpScaled.Height; j++) {
|
||||||
f.data[i, j] = iform.bmpScaled.GetPixel(i, j).ToArgb().Equals(Color.Black.ToArgb());
|
f.data[i, j] = iform.bmpScaled.GetPixel(i, j).ToArgb().Equals(Color.Black.ToArgb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.AddPost(f);
|
//history.AddPost(f);
|
||||||
|
history.Add(f);
|
||||||
CheckHistoryButtons();
|
CheckHistoryButtons();
|
||||||
dotPanel.Refresh();
|
dotPanel.Refresh();
|
||||||
SetModified();
|
SetModified();
|
||||||
|
1
TODO.txt
1
TODO.txt
@@ -3,6 +3,7 @@ Application:
|
|||||||
V Copy-Paste now uses System clipboard and it is possible to copy-paste from/to different instances of running program
|
V Copy-Paste now uses System clipboard and it is possible to copy-paste from/to different instances of running program
|
||||||
|
|
||||||
Functionality:
|
Functionality:
|
||||||
|
- Rewrite history class so it tracks all changes, not only a canvas changes
|
||||||
|
|
||||||
Bugs:
|
Bugs:
|
||||||
- In some cases after switching to a symbol dotPanel mouse move causes "Out of range" exception (history.Pre after width change?)
|
- In some cases after switching to a symbol dotPanel mouse move causes "Out of range" exception (history.Pre after width change?)
|
||||||
|
Reference in New Issue
Block a user