Version changed to 2.4; TODO features:

Application:
- Copy-Paste now uses System clipboard and it is possible to copy-paste from/to different instances of running program

Bugs fixed:
- Switching between symbols while select tool is active and small area selected trows an error
- Full frame Copy in Clipboard does not respect selection on Paste operation
This commit is contained in:
Anton Mukhin
2025-05-29 19:44:33 +03:00
parent eda7af8f67
commit 679b4fc61d
4 changed files with 67 additions and 64 deletions

View File

@@ -64,10 +64,12 @@
openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
importTextToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
importImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
exportFontLayoutPNGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -84,6 +86,7 @@
removeBeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
removeAfterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
CodeShiftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
testFontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
canvasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
ClearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -110,9 +113,6 @@
lblSelection = new System.Windows.Forms.Label();
lblModified = new System.Windows.Forms.Label();
dlgSavePNG = new System.Windows.Forms.SaveFileDialog();
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
((System.ComponentModel.ISupportInitialize)nudX).BeginInit();
((System.ComponentModel.ISupportInitialize)nudY).BeginInit();
panel1.SuspendLayout();
@@ -535,7 +535,7 @@
//
fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { newToolStripMenuItem, openToolStripMenuItem, saveToolStripMenuItem, saveAsToolStripMenuItem, toolStripSeparator1, importTextToolStripMenuItem1, importImageToolStripMenuItem, exportToolStripMenuItem, exportFontLayoutPNGToolStripMenuItem, toolStripSeparator2, exitToolStripMenuItem });
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
fileToolStripMenuItem.Size = new System.Drawing.Size(122, 20);
fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
fileToolStripMenuItem.Text = "File";
//
// newToolStripMenuItem
@@ -582,6 +582,11 @@
saveAsToolStripMenuItem.ToolTipText = "Save changes to another file";
saveAsToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
//
// toolStripSeparator1
//
toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new System.Drawing.Size(221, 6);
//
// importTextToolStripMenuItem1
//
importTextToolStripMenuItem1.Image = Properties.Resources.folder_table;
@@ -620,6 +625,11 @@
exportFontLayoutPNGToolStripMenuItem.ToolTipText = "Create an image with all a table showing all 256 symbols";
exportFontLayoutPNGToolStripMenuItem.Click += ExportPNG;
//
// toolStripSeparator2
//
toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new System.Drawing.Size(221, 6);
//
// exitToolStripMenuItem
//
exitToolStripMenuItem.Image = Properties.Resources.Famfamfam_Silk_Door_out_16;
@@ -672,7 +682,6 @@
//
// pasteToolStripMenuItem
//
pasteToolStripMenuItem.Enabled = false;
pasteToolStripMenuItem.Image = Properties.Resources.Famfamfam_Silk_Page_paste_16;
pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
pasteToolStripMenuItem.ShortcutKeyDisplayString = "";
@@ -785,6 +794,11 @@
CodeShiftToolStripMenuItem.ToolTipText = "Shift the font on the code line";
CodeShiftToolStripMenuItem.Click += CodeShiftToolStripMenuItem_Click;
//
// toolStripSeparator3
//
toolStripSeparator3.Name = "toolStripSeparator3";
toolStripSeparator3.Size = new System.Drawing.Size(212, 6);
//
// testFontToolStripMenuItem
//
testFontToolStripMenuItem.Image = Properties.Resources.font;
@@ -1055,21 +1069,6 @@
dlgSavePNG.DefaultExt = "png";
dlgSavePNG.Filter = "PNG Image|*.png;*.PNG";
//
// toolStripSeparator1
//
toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new System.Drawing.Size(221, 6);
//
// toolStripSeparator2
//
toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new System.Drawing.Size(221, 6);
//
// toolStripSeparator3
//
toolStripSeparator3.Name = "toolStripSeparator3";
toolStripSeparator3.Size = new System.Drawing.Size(212, 6);
//
// MainForm
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);

View File

@@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Windows.Forms;
@@ -52,18 +53,18 @@ namespace McBitFont {
private CanvasHistory history = new();
private int cellSize = 10;
public int dotWidth, dotHeight;
private int pixelOffset = 5;
private readonly int pixelOffset = 5;
private int gap;
private int w, h;
public bool monospaced = false;
private bool modified = false;
private bool prjModified = false;
public const string version = "2.3";
public const string version = "2.4";
public string prjName = "Untitled";
public string prjFileName = "";
public int codepage = 1251;
private FrameMiniature fbuf;
private bool fbuffer = false;
private readonly DataFormats.Format clpbFormat = DataFormats.GetFormat("McBitFontFrame");
private int baseline = 0;
private bool set_base = false;
private Point selection1, selection2;
@@ -148,8 +149,8 @@ namespace McBitFont {
}
private FrameMiniature CopyFrame(FrameMiniature frame, bool clipboard = false) {
int width = chkRectSelect.Checked ? selection2.X - selection1.X + 1 : frame.width;
int height = chkRectSelect.Checked ? selection2.Y - selection1.Y + 1 : frame.height;
int width = chkRectSelect.Checked && clipboard ? selection2.X - selection1.X + 1 : frame.width;
int height = chkRectSelect.Checked && clipboard ? selection2.Y - selection1.Y + 1 : frame.height;
var ff = new FrameMiniature(frame.code, width, height);
if (chkRectSelect.Checked && clipboard) {
@@ -817,7 +818,6 @@ namespace McBitFont {
SetWindowCap();
SetModified(false); ;
CheckForAdd();
fbuffer = false;
miniList.Items[0].Selected = true;
miniList.Refresh();
dotPanel.Refresh();
@@ -839,10 +839,8 @@ namespace McBitFont {
tsmiRemoveSymbol.Enabled = false;
tsmiRemoveBefore.Enabled = false;
tsmiRemoveAfter.Enabled = false;
//copyToolStripMenuItem.Enabled = false;
pasteToolStripMenuItem.Enabled = false;
return;
//miniList.Items[0].Selected = true;
}
// Clear history
@@ -863,7 +861,7 @@ namespace McBitFont {
removeSymbolToolStripMenuItem.Enabled = false;
tsmiRemoveSymbol.Enabled = false;
}
//copyToolStripMenuItem.Enabled = true;
if (frames.Count > 1 && ff.Equals(frames.First())) {
removeBeforeToolStripMenuItem.Enabled = false;
removeAfterToolStripMenuItem.Enabled = true;
@@ -881,8 +879,6 @@ namespace McBitFont {
tsmiRemoveAfter.Enabled = true;
}
if (fbuffer) pasteToolStripMenuItem.Enabled = true;
else pasteToolStripMenuItem.Enabled = false;
}
private void SaveToolStripMenuItem_Click(object sender, EventArgs e) {
@@ -940,8 +936,6 @@ namespace McBitFont {
miniList.Items[0].Selected = true;
CheckForAdd();
fbuffer = false;
//copyToolStripMenuItem.Enabled = true;
// Re-create history object
history = new CanvasHistory();
@@ -1041,37 +1035,44 @@ namespace McBitFont {
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e) {
fbuffer = true;
fbuf = CopyFrame(f, true);
pasteToolStripMenuItem.Enabled = true;
var bb = MessagePackSerializer.Serialize(CopyFrame(f, true));
DataObject clpbObj = new DataObject(clpbFormat.Name, bb);
Clipboard.SetDataObject(clpbObj, true);
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) {
history.AddPre(f);
if (fbuf.width == f.width && fbuf.height == f.height) {
Array.Copy(fbuf.data, f.data, fbuf.data.Length);
} else {
int di, dj, wmax, hmax, selw, selh;
if (chkRectSelect.Checked) {
di = selection1.X;
dj = selection1.Y;
selw = selection2.X - selection1.X + 1;
selh = selection2.Y - selection1.Y + 1;
wmax = fbuf.width > selw ? selw : fbuf.width;
hmax = fbuf.height > selh ? selh : fbuf.height;
} else {
di = 0;
dj = 0;
wmax = (fbuf.width > f.width) ? f.width : fbuf.width;
hmax = (fbuf.height > f.height) ? f.height : fbuf.height;
}
// Try to read from clipboard
try {
IDataObject clpbObj = Clipboard.GetDataObject();
byte[] bb = (byte[])clpbObj.GetData(clpbFormat.Name);
fbuf = MessagePackSerializer.Deserialize<FrameMiniature>(bb);
}
catch {
return;
}
for (int i = 0; i < wmax; i++) {
for (int j = 0; j < hmax; j++) {
f.data[i + di, j + dj] = fbuf.data[i, j];
}
history.AddPre(f);
int di, dj, wmax, hmax, selw, selh;
if (chkRectSelect.Checked) {
di = selection1.X;
dj = selection1.Y;
selw = selection2.X - selection1.X + 1;
selh = selection2.Y - selection1.Y + 1;
wmax = fbuf.width > selw ? selw : fbuf.width;
hmax = fbuf.height > selh ? selh : fbuf.height;
} else {
di = 0;
dj = 0;
wmax = (fbuf.width > f.width) ? f.width : fbuf.width;
hmax = (fbuf.height > f.height) ? f.height : fbuf.height;
}
for (int i = 0; i < wmax; i++) {
for (int j = 0; j < hmax; j++) {
f.data[i + di, j + dj] = fbuf.data[i, j];
}
}
history.AddPost(f);
CheckHistoryButtons();
dotPanel.Refresh();
@@ -1436,7 +1437,7 @@ namespace McBitFont {
private void ExportPNG(object sender, EventArgs e) {
CheckModifiedFrame();
CheckModifiedProject();
if (dlgSavePNG.ShowDialog() == DialogResult.OK) {
int pixelSize = 3;
int symbolMargin = 2 * pixelSize;
@@ -1474,7 +1475,7 @@ namespace McBitFont {
g.DrawString("First code: " + frames.First().code.ToString(), font, tb, 250, 38);
g.DrawString("Last code: " + frames.Last().code.ToString(), font, tb, 250, 62);
g.DrawString("Codepage: " + codepage.ToString(), font, tb, 250, 86);
// Draw grid
Pen p = new(Color.FromArgb(64, 0, 0, 0), 1);

View File

@@ -20,9 +20,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ApplicationIcon>icon_64.ico</ApplicationIcon>
<AssemblyVersion>2.3.0.0</AssemblyVersion>
<FileVersion>2.3.0.0</FileVersion>
<Version>$(VersionPrefix)2.3.0</Version>
<AssemblyVersion>2.4.0.0</AssemblyVersion>
<FileVersion>2.4.0.0</FileVersion>
<Version>$(VersionPrefix)2.4.0</Version>
<Copyright>Anton Mukhin</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -1,5 +1,6 @@
Application:
- Consider migrating to WPF in order to make DPI aware UI
V Copy-Paste now uses System clipboard and it is possible to copy-paste from/to different instances of running program
Functionality:
V Allow to add frames to Single-frame "fonts"
@@ -8,3 +9,5 @@ V Export image with All characers table
Bugs:
- In some cases after switching to a symbol dotPanel mouse move causes "Out of range" exception (history.Pre after width change?)
V Switching between symbols while select tool is active and small area selected trows an error
V Full frame Copy in Clipboard does not respect selection on Paste operation