From c1a8d30760bd4eb0fd2eef9a74ba05fb8223b9e4 Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Fri, 23 May 2025 18:48:28 +0300 Subject: [PATCH] TODO features and Bug fixed: Application: - Option to display codes in Hex numbers - Make symbol list wider to display 8 characters instead of 7 Bugs: - Wrongly mark Project as modified on symbol selection --- McBitFont/Form1.Designer.cs | 41 ++++++++++++++++++++++++----------- McBitFont/Form1.cs | 43 ++++++++++++++++++++++++++++--------- TODO.txt | 5 +++-- 3 files changed, 65 insertions(+), 24 deletions(-) diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs index 1c3f87e..5498b4a 100644 --- a/McBitFont/Form1.Designer.cs +++ b/McBitFont/Form1.Designer.cs @@ -97,6 +97,7 @@ chkLeftSide = new System.Windows.Forms.CheckBox(); chkTopSide = new System.Windows.Forms.CheckBox(); label3 = new System.Windows.Forms.Label(); + chkHexCodes = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)nudX).BeginInit(); ((System.ComponentModel.ISupportInitialize)nudY).BeginInit(); panel1.SuspendLayout(); @@ -112,7 +113,7 @@ dotPanel.Location = new System.Drawing.Point(14, 31); dotPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); dotPanel.Name = "dotPanel"; - dotPanel.Size = new System.Drawing.Size(454, 575); + dotPanel.Size = new System.Drawing.Size(427, 575); dotPanel.TabIndex = 0; dotPanel.Paint += dotPanel_Paint; dotPanel.MouseDown += dotPanel_MouseMove; @@ -171,10 +172,10 @@ // lblType // lblType.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - lblType.Location = new System.Drawing.Point(646, 159); + lblType.Location = new System.Drawing.Point(718, 159); lblType.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); lblType.Name = "lblType"; - lblType.Size = new System.Drawing.Size(253, 15); + lblType.Size = new System.Drawing.Size(181, 15); lblType.TabIndex = 0; lblType.Text = "Monospaced"; lblType.TextAlign = System.Drawing.ContentAlignment.TopRight; @@ -185,7 +186,7 @@ cbZoom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; cbZoom.FormattingEnabled = true; cbZoom.Items.AddRange(new object[] { "2", "3", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50" }); - cbZoom.Location = new System.Drawing.Point(646, 52); + cbZoom.Location = new System.Drawing.Point(619, 52); cbZoom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); cbZoom.Name = "cbZoom"; cbZoom.Size = new System.Drawing.Size(68, 23); @@ -197,7 +198,7 @@ // label4.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; label4.AutoSize = true; - label4.Location = new System.Drawing.Point(645, 33); + label4.Location = new System.Drawing.Point(618, 33); label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); label4.Name = "label4"; label4.Size = new System.Drawing.Size(69, 15); @@ -216,7 +217,7 @@ panel1.Controls.Add(btnShiftUp); panel1.Controls.Add(btnShiftRight); panel1.Controls.Add(btnShiftLeft); - panel1.Location = new System.Drawing.Point(499, 31); + panel1.Location = new System.Drawing.Point(472, 31); panel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); panel1.Name = "panel1"; panel1.Size = new System.Drawing.Size(140, 139); @@ -342,17 +343,17 @@ // miniList // miniList.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + miniList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; miniList.ContextMenuStrip = cmMinilist; miniList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); - miniList.GridLines = true; miniList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; miniList.LargeImageList = ilMiniatures; - miniList.Location = new System.Drawing.Point(499, 178); + miniList.Location = new System.Drawing.Point(472, 178); miniList.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); miniList.MultiSelect = false; miniList.Name = "miniList"; miniList.ShowGroups = false; - miniList.Size = new System.Drawing.Size(400, 455); + miniList.Size = new System.Drawing.Size(427, 455); miniList.SmallImageList = ilMiniatures; miniList.Sorting = System.Windows.Forms.SortOrder.Ascending; miniList.TabIndex = 12; @@ -467,7 +468,7 @@ // vScroll.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; vScroll.LargeChange = 25; - vScroll.Location = new System.Drawing.Point(471, 31); + vScroll.Location = new System.Drawing.Point(444, 31); vScroll.Name = "vScroll"; vScroll.Size = new System.Drawing.Size(21, 575); vScroll.TabIndex = 15; @@ -477,7 +478,7 @@ // lblCoords.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; lblCoords.AutoSize = true; - lblCoords.Location = new System.Drawing.Point(643, 132); + lblCoords.Location = new System.Drawing.Point(616, 132); lblCoords.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); lblCoords.Name = "lblCoords"; lblCoords.Size = new System.Drawing.Size(24, 15); @@ -852,6 +853,7 @@ // // chkLeftSide // + chkLeftSide.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; chkLeftSide.AutoSize = true; chkLeftSide.Location = new System.Drawing.Point(831, 33); chkLeftSide.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); @@ -864,6 +866,7 @@ // // chkTopSide // + chkTopSide.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; chkTopSide.AutoSize = true; chkTopSide.Location = new System.Drawing.Point(831, 58); chkTopSide.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); @@ -876,18 +879,31 @@ // // label3 // + label3.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; label3.AutoSize = true; - label3.Location = new System.Drawing.Point(642, 117); + label3.Location = new System.Drawing.Point(615, 117); label3.Name = "label3"; label3.Size = new System.Drawing.Size(45, 15); label3.TabIndex = 21; label3.Text = "Cursor:"; // + // chkHexCodes + // + chkHexCodes.AutoSize = true; + chkHexCodes.Location = new System.Drawing.Point(618, 155); + chkHexCodes.Name = "chkHexCodes"; + chkHexCodes.Size = new System.Drawing.Size(95, 19); + chkHexCodes.TabIndex = 22; + chkHexCodes.Text = "Codes in Hex"; + chkHexCodes.UseVisualStyleBackColor = true; + chkHexCodes.CheckedChanged += chkHexCodes_CheckedChanged; + // // MainForm // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ClientSize = new System.Drawing.Size(915, 647); + Controls.Add(chkHexCodes); Controls.Add(label3); Controls.Add(chkTopSide); Controls.Add(chkLeftSide); @@ -1002,6 +1018,7 @@ private System.Windows.Forms.ToolStripMenuItem tsmiMakeVarWidth; private System.Windows.Forms.ToolStripMenuItem importImageToolStripMenuItem; private System.Windows.Forms.Label label3; + private System.Windows.Forms.CheckBox chkHexCodes; } } diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 2a0bf8d..598af25 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -93,7 +93,7 @@ namespace McBitFont { miniList.Select(); f = CopyFrame(frames.Find(x => x.code == 0)); - ListViewItem_SetSpacing(miniList, 50 + 2, 50 + 22); + ListViewItem_SetSpacing(miniList, 50 + 1, 50 + 22); SetWindowCap(); @@ -115,11 +115,11 @@ namespace McBitFont { [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); - public int MakeLong(short lowPart, short highPart) { + public static int MakeLong(short lowPart, short highPart) { return (int)(((ushort)lowPart) | (uint)(highPart << 16)); } - FrameMiniature CopyFrame(FrameMiniature frame) { + private static FrameMiniature CopyFrame(FrameMiniature frame) { var ff = new FrameMiniature(frame.code, frame.width, frame.height); Array.Copy(frame.data, ff.data, frame.data.Length); return ff; @@ -168,10 +168,12 @@ namespace McBitFont { ilMiniatures.Images.Add(s, (Image)bmp); miniList.Items[s].ImageKey = s; } - } else { - if (nudX.Focused) modified = true; } - prjModified = true; + if (nudX.Focused) { + modified = true; + prjModified = true; + } + dotResize((int)nudX.Value, dotHeight); Cursor.Current = Cursors.Default; } @@ -187,8 +189,11 @@ namespace McBitFont { ilMiniatures.Images.Add(s, (Image)bmp); miniList.Items[s].ImageKey = s; } - if (nudY.Focused) modified = true; - prjModified = true; + if (nudY.Focused) { + modified = true; + prjModified = true; + } + dotResize(dotWidth, (int)nudY.Value); Cursor.Current = Cursors.Default; } @@ -741,6 +746,7 @@ namespace McBitFont { private void LoadProject(string filename) { SaveBlock sav; + Cursor.Current = Cursors.WaitCursor; using (FileStream fs = File.Open(filename, FileMode.Open)) { sav = MessagePackSerializer.Deserialize(fs); fs.Close(); @@ -756,9 +762,10 @@ namespace McBitFont { ilMiniatures.Images.Clear(); foreach (FrameMiniature ff in frames) { 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, s + ' ' + sss, s); + miniList.Items.Add(s, (chkHexCodes.Checked ? sHex : s) + ' ' + sss, s); } nudX.ValueChanged -= nudX_ValueChanged; nudY.ValueChanged -= nudY_ValueChanged; @@ -789,6 +796,7 @@ namespace McBitFont { makeVarWidthToolStripMenuItem.Visible = monospaced; tsmiCodeShift.Visible = frames.Count > 1; CodeShiftToolStripMenuItem.Visible = frames.Count > 1; + Cursor.Current = Cursors.Default; } private void SaveProject(string filename) { @@ -1066,7 +1074,7 @@ namespace McBitFont { history.AddPre(f); for (int i = 0; i < iform.bmpScaled.Width; i++) { 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); @@ -1075,5 +1083,20 @@ namespace McBitFont { } iform.Dispose(); } + + private void chkHexCodes_CheckedChanged(object sender, EventArgs e) { + if (frames.Count == 1) return; + foreach (ListViewItem item in miniList.Items) { + var code = Convert.ToInt32(item.ImageKey); + var symbol = decodeSymbol(code); + if (chkHexCodes.Checked) { + var sHex = 'x' + Convert.ToString(code, 16).PadLeft(2, '0').ToUpper(); + item.Text = sHex + ' ' + symbol; + } else { + item.Text = item.ImageKey + ' ' + symbol; + } + + } + } } } diff --git a/TODO.txt b/TODO.txt index 6fda64c..1e4f44c 100644 --- a/TODO.txt +++ b/TODO.txt @@ -5,8 +5,8 @@ V Better quality pictures in symbol list V Spinning cursor when application is busy V Change Menu icons V Re-arranged menu items -- Option to display codes in Hex numbers -- Make symbol list wider to display 8 characters instead of 7 +V Option to display codes in Hex numbers +V Make symbol list wider to display 8 characters instead of 7 Functionality: V Context menu in symbol navigator @@ -24,3 +24,4 @@ V "Bytes total comment in export Bugs: V Improper bytes count for 16 or 32 bit numbers export V Exception on Code Shift when nothing is selected in Symbols List +V Wrongly mark Project as modified on symbol selection