diff --git a/McBitFont/Export.cs b/McBitFont/Export.cs index 338ad2c..e399fa6 100644 --- a/McBitFont/Export.cs +++ b/McBitFont/Export.cs @@ -233,7 +233,12 @@ namespace McBitFont { if (com && lines != 1 && fcount > 1) { // Comments enabled and other than "1 symbol per line" selected // Print a symbol comment before its data - output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code); + string character = f.code switch { + 92 => "Backslash", + _ => mainForm.DecodeSymbol(f.code), + }; + string code = mainForm.chkHexCodes.Checked ? "0x" + Convert.ToString(f.code, 16).PadLeft(2, '0').ToUpper() : f.code.ToString(); + output += " // " + code + " --> " + character; if (f.note != "" && f.note != null) output += " (" + f.note.ToString() + ")"; output += "\n"; } @@ -371,7 +376,12 @@ namespace McBitFont { if (!f.Equals(flast) && f.width > 0) output += ","; if (com && fcount > 1) { //...with a comment - output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code); + string character = f.code switch { + 92 => "Backslash", + _ => mainForm.DecodeSymbol(f.code), + }; + string code = mainForm.chkHexCodes.Checked ? "0x" + Convert.ToString(f.code, 16).PadLeft(2, '0').ToUpper() : f.code.ToString(); + output += " // " + code + " --> " + character; if (f.note != "" && f.note != null) output += " (" + f.note.ToString() + ")"; } output += "\n"; diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs index d8829d9..dba0848 100644 --- a/McBitFont/Form1.Designer.cs +++ b/McBitFont/Form1.Designer.cs @@ -1216,13 +1216,13 @@ // cmBaseline.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { tsmiTopline, tsmiMidline, tsmiBaseline }); cmBaseline.Name = "cmBaseline"; - cmBaseline.Size = new System.Drawing.Size(181, 92); + cmBaseline.Size = new System.Drawing.Size(121, 70); // // tsmiTopline // tsmiTopline.Image = Properties.Resources.fam_top; tsmiTopline.Name = "tsmiTopline"; - tsmiTopline.Size = new System.Drawing.Size(180, 22); + tsmiTopline.Size = new System.Drawing.Size(120, 22); tsmiTopline.Text = "Top line"; tsmiTopline.ToolTipText = "Set top base line"; tsmiTopline.Click += tsmiTopline_Click; @@ -1231,7 +1231,7 @@ // tsmiMidline.Image = Properties.Resources.fam_mid; tsmiMidline.Name = "tsmiMidline"; - tsmiMidline.Size = new System.Drawing.Size(180, 22); + tsmiMidline.Size = new System.Drawing.Size(120, 22); tsmiMidline.Text = "Mid line"; tsmiMidline.ToolTipText = "Set middle base line"; tsmiMidline.Click += tsmiMidline_Click; @@ -1240,7 +1240,7 @@ // tsmiBaseline.Image = Properties.Resources.fam_base; tsmiBaseline.Name = "tsmiBaseline"; - tsmiBaseline.Size = new System.Drawing.Size(180, 22); + tsmiBaseline.Size = new System.Drawing.Size(120, 22); tsmiBaseline.Text = "Base line"; tsmiBaseline.ToolTipText = "Set bottom (base) line"; tsmiBaseline.Click += tsmiBaseline_Click; @@ -1358,7 +1358,6 @@ private System.Windows.Forms.ToolStripMenuItem tsmiMakeVarWidth; private System.Windows.Forms.ToolStripMenuItem importImageToolStripMenuItem; private System.Windows.Forms.Label label3; - private System.Windows.Forms.CheckBox chkHexCodes; private System.Windows.Forms.Button btnFill; private System.Windows.Forms.ToolStripMenuItem FillToolStripMenuItem; private System.Windows.Forms.CheckBox chkRectSelect; @@ -1393,6 +1392,7 @@ private System.Windows.Forms.ToolStripMenuItem tsmiBaseline; private System.Windows.Forms.ToolStripMenuItem tsmiMidline; private System.Windows.Forms.ToolStripMenuItem tsmiTopline; + public System.Windows.Forms.CheckBox chkHexCodes; } } diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 01d977b..9e869bb 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -63,7 +63,6 @@ namespace McBitFont { public FrameMiniature f; public List frames = new List(); - //private CanvasHistory history = new(); private ChangeHistory history; private int cellSize = 10; public int dotWidth, dotHeight; @@ -73,7 +72,7 @@ namespace McBitFont { public bool monospaced = false; private bool modified = false; private bool prjModified = false; - public const string version = "2.9"; + public const string version = "2.10"; public string prjName = "Untitled"; public string prjFileName = ""; public int codepage = 1251; @@ -83,6 +82,7 @@ namespace McBitFont { private SetLines set_lines = SetLines.SL_None; private Point selection1, selection2; private Point[,] sidebarLocs = new Point[2, 3]; + private bool frameClipboard = false; public MainForm() { @@ -475,6 +475,9 @@ namespace McBitFont { var rectSel = chkRectSelect.Checked; bool rectSelUpdated = false; + // Set input focus to minilist if any mouse button is held + if (!miniList.Focused && e.Button != MouseButtons.None) miniList.Focus(); + // Drag with middle mouse button if (vScroll.Enabled || hScroll.Enabled) { if (mouseDownMiddle) { @@ -1182,47 +1185,58 @@ namespace McBitFont { } private void copyToolStripMenuItem_Click(object sender, EventArgs e) { - var bb = MessagePackSerializer.Serialize(CopyFrame(f, true)); - DataObject clpbObj = new DataObject(clpbFormat.Name, bb); - Clipboard.SetDataObject(clpbObj, true); + if (tbFrameNote.Focused) { + tbFrameNote.Copy(); + frameClipboard = false; + } else { + var bb = MessagePackSerializer.Serialize(CopyFrame(f, true)); + DataObject clpbObj = new DataObject(clpbFormat.Name, bb); + Clipboard.SetDataObject(clpbObj, true); + frameClipboard = true; + } + } private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { - // Try to read from clipboard - try { - IDataObject clpbObj = Clipboard.GetDataObject(); - byte[] bb = (byte[])clpbObj.GetData(clpbFormat.Name); - fbuf = MessagePackSerializer.Deserialize(bb); - } - catch { - return; - } - - 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]; + if (tbFrameNote.Focused) { + if (!frameClipboard) tbFrameNote.Paste(); + } else if (frameClipboard) { + // Try to read from clipboard + try { + IDataObject clpbObj = Clipboard.GetDataObject(); + byte[] bb = (byte[])clpbObj.GetData(clpbFormat.Name); + fbuf = MessagePackSerializer.Deserialize(bb); + } + catch { + return; } - } - history.Add(f); - CheckHistoryButtons(); - dotPanel.Refresh(); - SetModified(); + 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.Add(f); + CheckHistoryButtons(); + dotPanel.Refresh(); + SetModified(); + } } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { @@ -1239,8 +1253,8 @@ namespace McBitFont { if (modified) { if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveFrame(); - SetModified(false); } + SetModified(false); } } diff --git a/McBitFont/McBitFont.csproj b/McBitFont/McBitFont.csproj index 094edfd..c5eed02 100644 --- a/McBitFont/McBitFont.csproj +++ b/McBitFont/McBitFont.csproj @@ -20,9 +20,9 @@ true true icon_64.ico - 2.9.0.0 - 2.9.0.0 - $(VersionPrefix)2.9.0 + 2.10.0.0 + 2.10.0.0 + $(VersionPrefix)2.10.0 Anton Mukhin diff --git a/TODO.txt b/TODO.txt index 3fddb76..30b23dd 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,11 +1,11 @@ Application: - Consider migrating to WPF in order to make DPI aware UI - +V Export comments now respects "Code in Hex" checkbox on the main form Functionality: Bugs: -- Frame modified flag persists when switching to another frame after rejected to save previous frame -- Ctrl-C, Ctrl-V doesn't work in the Note editbox because it tries to copy/paste the frame! -- Post "Backslash" instead of \ in comments \ No newline at end of file +V Frame modified flag persists when switching to another frame after rejected to save previous frame +V Ctrl-C, Ctrl-V doesn't work in the Note editbox because it tries to copy/paste the frame! +V Post "Backslash" instead of \ in comments \ No newline at end of file