5 Commits

Author SHA1 Message Date
Anton Mukhin
cc161169f1 Add icons 9x9 example 2023-05-12 16:28:12 +03:00
Anton Mukhin
0ba03444d1 Add/Remove symbols 2023-05-12 14:08:21 +03:00
Anton Mukhin
302977c3f4 Export is done (I think) 2023-05-12 10:59:35 +03:00
a89bbc59ed Merge branch 'rich-text-experiment' 2023-05-12 04:37:24 +03:00
691b87b842 WIP: working on text formats 2023-05-12 04:35:26 +03:00
5 changed files with 275 additions and 84 deletions

View File

@@ -37,8 +37,8 @@
this.cbNumSize = new System.Windows.Forms.ComboBox(); this.cbNumSize = new System.Windows.Forms.ComboBox();
this.cbNumBase = new System.Windows.Forms.ComboBox(); this.cbNumBase = new System.Windows.Forms.ComboBox();
this.gbText = new System.Windows.Forms.GroupBox(); this.gbText = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label(); this.lblXLines = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.nudXLines = new System.Windows.Forms.NumericUpDown();
this.cbLines = new System.Windows.Forms.ComboBox(); this.cbLines = new System.Windows.Forms.ComboBox();
this.cbFormat = new System.Windows.Forms.ComboBox(); this.cbFormat = new System.Windows.Forms.ComboBox();
this.btnGenerate = new System.Windows.Forms.Button(); this.btnGenerate = new System.Windows.Forms.Button();
@@ -47,7 +47,7 @@
this.gbOptions.SuspendLayout(); this.gbOptions.SuspendLayout();
this.gbNumbers.SuspendLayout(); this.gbNumbers.SuspendLayout();
this.gbText.SuspendLayout(); this.gbText.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudXLines)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// txtOutput // txtOutput
@@ -65,6 +65,7 @@
this.txtOutput.Size = new System.Drawing.Size(529, 507); this.txtOutput.Size = new System.Drawing.Size(529, 507);
this.txtOutput.TabIndex = 0; this.txtOutput.TabIndex = 0;
this.txtOutput.Text = ""; this.txtOutput.Text = "";
this.txtOutput.WordWrap = false;
// //
// gbScan // gbScan
// //
@@ -216,8 +217,8 @@
// //
// gbText // gbText
// //
this.gbText.Controls.Add(this.label1); this.gbText.Controls.Add(this.lblXLines);
this.gbText.Controls.Add(this.numericUpDown1); this.gbText.Controls.Add(this.nudXLines);
this.gbText.Controls.Add(this.cbLines); this.gbText.Controls.Add(this.cbLines);
this.gbText.Controls.Add(this.cbFormat); this.gbText.Controls.Add(this.cbFormat);
this.gbText.Location = new System.Drawing.Point(5, 234); this.gbText.Location = new System.Drawing.Point(5, 234);
@@ -227,34 +228,34 @@
this.gbText.TabStop = false; this.gbText.TabStop = false;
this.gbText.Text = "Text format"; this.gbText.Text = "Text format";
// //
// label1 // lblXLines
// //
this.label1.AutoSize = true; this.lblXLines.AutoSize = true;
this.label1.Enabled = false; this.lblXLines.Enabled = false;
this.label1.Location = new System.Drawing.Point(10, 76); this.lblXLines.Location = new System.Drawing.Point(10, 76);
this.label1.Name = "label1"; this.lblXLines.Name = "lblXLines";
this.label1.Size = new System.Drawing.Size(60, 13); this.lblXLines.Size = new System.Drawing.Size(60, 13);
this.label1.TabIndex = 9; this.lblXLines.TabIndex = 9;
this.label1.Text = "X numbers:"; this.lblXLines.Text = "X numbers:";
// //
// numericUpDown1 // nudXLines
// //
this.numericUpDown1.Enabled = false; this.nudXLines.Enabled = false;
this.numericUpDown1.Location = new System.Drawing.Point(76, 73); this.nudXLines.Location = new System.Drawing.Point(76, 73);
this.numericUpDown1.Maximum = new decimal(new int[] { this.nudXLines.Maximum = new decimal(new int[] {
64, 64,
0, 0,
0, 0,
0}); 0});
this.numericUpDown1.Minimum = new decimal(new int[] { this.nudXLines.Minimum = new decimal(new int[] {
1, 1,
0, 0,
0, 0,
0}); 0});
this.numericUpDown1.Name = "numericUpDown1"; this.nudXLines.Name = "nudXLines";
this.numericUpDown1.Size = new System.Drawing.Size(55, 20); this.nudXLines.Size = new System.Drawing.Size(55, 20);
this.numericUpDown1.TabIndex = 8; this.nudXLines.TabIndex = 8;
this.numericUpDown1.Value = new decimal(new int[] { this.nudXLines.Value = new decimal(new int[] {
8, 8,
0, 0,
0, 0,
@@ -272,6 +273,7 @@
this.cbLines.Name = "cbLines"; this.cbLines.Name = "cbLines";
this.cbLines.Size = new System.Drawing.Size(121, 21); this.cbLines.Size = new System.Drawing.Size(121, 21);
this.cbLines.TabIndex = 7; this.cbLines.TabIndex = 7;
this.cbLines.SelectedIndexChanged += new System.EventHandler(this.cbLines_SelectedIndexChanged);
// //
// cbFormat // cbFormat
// //
@@ -333,7 +335,7 @@
this.gbNumbers.ResumeLayout(false); this.gbNumbers.ResumeLayout(false);
this.gbText.ResumeLayout(false); this.gbText.ResumeLayout(false);
this.gbText.PerformLayout(); this.gbText.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudXLines)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -353,8 +355,8 @@
private System.Windows.Forms.ComboBox cbNumSize; private System.Windows.Forms.ComboBox cbNumSize;
private System.Windows.Forms.ComboBox cbNumBase; private System.Windows.Forms.ComboBox cbNumBase;
private System.Windows.Forms.GroupBox gbText; private System.Windows.Forms.GroupBox gbText;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lblXLines;
private System.Windows.Forms.NumericUpDown numericUpDown1; private System.Windows.Forms.NumericUpDown nudXLines;
private System.Windows.Forms.ComboBox cbLines; private System.Windows.Forms.ComboBox cbLines;
private System.Windows.Forms.ComboBox cbFormat; private System.Windows.Forms.ComboBox cbFormat;
private System.Windows.Forms.Button btnGenerate; private System.Windows.Forms.Button btnGenerate;

View File

@@ -81,6 +81,11 @@ namespace McBitFont {
bool hdr = cbHeader.Checked; bool hdr = cbHeader.Checked;
int lines = cbLines.SelectedIndex; int lines = cbLines.SelectedIndex;
int format = cbFormat.SelectedIndex; int format = cbFormat.SelectedIndex;
bool mono = mainForm.monospaced;
int lineslim = (int)nudXLines.Value;
int fcount = mainForm.frames.Count;
int imin, jmin, imax, jmax, idir, jdir;
if (com) { if (com) {
//Header comments //Header comments
@@ -102,7 +107,7 @@ namespace McBitFont {
} }
} }
int imin, jmin, imax, jmax, idir, jdir; //Figure out mins and maxes
if (cbOrder.SelectedIndex == 0) { if (cbOrder.SelectedIndex == 0) {
if (cbHDir.SelectedIndex == 0) { if (cbHDir.SelectedIndex == 0) {
// Columns; Left to right // Columns; Left to right
@@ -127,28 +132,28 @@ namespace McBitFont {
jdir = -1; jdir = -1;
} }
} else { } else {
if (cbHDir.SelectedIndex == 0) {
// Rows; Left to right
jmin = 0;
jmax = mainForm.dotHeight;
jdir = 1;
} else {
// Rows; Right to left
jmin = mainForm.dotHeight - 1;
jmax = -1;
jdir = -1;
}
if (cbVDir.SelectedIndex == 0) { if (cbVDir.SelectedIndex == 0) {
// Rows; Top to bottom // Rows; Left to right
imin = 0; imin = 0;
imax = mainForm.dotWidth; imax = mainForm.dotHeight;
idir = 1; idir = 1;
} else { } else {
// Rows; Bottom to top // Rows; Right to left
imin = mainForm.dotWidth - 1; imin = mainForm.dotHeight - 1;
imax = -1; imax = -1;
idir = -1; idir = -1;
} }
if (cbHDir.SelectedIndex == 0) {
// Rows; Top to bottom
jmin = 0;
jmax = mainForm.dotWidth;
jdir = 1;
} else {
// Rows; Bottom to top
jmin = mainForm.dotWidth - 1;
jmax = -1;
jdir = -1;
}
} }
@@ -192,7 +197,19 @@ namespace McBitFont {
} }
// Array definition // Array definition
if ( format == 0 || format == 1 ) output += "const " + dataType + " " + mainForm.prjName + "[] = {\n"; if ( format == 0 || format == 1 ) output += "const " + dataType + " " + mainForm.prjName + "[]" + (format==1?"[]":"") + " = {\n";
// Should we add the meta header?
if (hdr) {
output +=
" // Meta header\n" +
" " + (mono ? mainForm.frames.First().width.ToString() : "0") + ", // Font width in pixels; 0 - variable width\n" +
" " + mainForm.frames.First().height.ToString() + ", // Font height in pixels\n" +
" 0, // Font space (between symbols) in pixels\n" +
" " + mainForm.frames.First().code.ToString() + ", // First character code\n" +
" " + mainForm.frames.Last().code.ToString() + ", // Last character code\n"
;
}
// Brackets for 2D array definition // Brackets for 2D array definition
string obracket = format == 1 ? "{ " : ""; string obracket = format == 1 ? "{ " : "";
@@ -202,13 +219,13 @@ namespace McBitFont {
int numcount = 0; int numcount = 0;
if (com) output += " // Data:\n"; if (com) output += " // Data:\n";
MainForm.FrameMiniature flast = mainForm.frames.Last();
foreach ( MainForm.FrameMiniature f in mainForm.frames) { foreach ( MainForm.FrameMiniature f in mainForm.frames) {
// For each frame // For each frame
string str;
uint b = 0; // current number bits uint b = 0; // current number bits
int t, x, y; // t - calculated bit number; x - actual x; y - actual y int t, x, y; // t - calculated bit number; x - actual x; y - actual y
if (com && lines != 1) { if (com && lines != 1 && fcount > 1) {
// Comments enabled and other than "1 symbol per line" selected // Comments enabled and other than "1 symbol per line" selected
// Print a symbol comment before its data // Print a symbol comment before its data
output += " // " + f.code.ToString() + " --> " + mainForm.decodeSymbol(f.code) + "\n"; output += " // " + f.code.ToString() + " --> " + mainForm.decodeSymbol(f.code) + "\n";
@@ -218,6 +235,60 @@ namespace McBitFont {
output += " "; output += " ";
numcount = 0; numcount = 0;
} }
if (!mono && fcount > 1) {
// Not a single image; Variable width font - lets post the width as a 1st number
// Should we post a prefix to the number?
pref = (!cbZeroes.Checked && ((f.width < 10 && nbase == 16) || (f.width < 2 && nbase == 2))) ? "" : prefix;
output += (lines != 1 ? " " : "") + pref + Convert.ToString(f.width, nbase).PadLeft(pad, '0') + (lines != 0 ? (lines == 1 ? ", " : "") : ",\n");
// Count posted numbers
numcount++;
if (lines != 2) numcount = 0;
if (lines == 2 && numcount >= lineslim) {
numcount = 0;
output += "\n ";
}
}
if (lines == 2 && numcount == 0) {
// "X numbers per line" - first line of a symbol offset
output += " ";
}
//Figure out mins and maxes for variable width fonts
if (!mono && fcount > 1) {
if (cbOrder.SelectedIndex == 0) {
if (cbHDir.SelectedIndex == 0) {
// Columns; Left to right
imax = f.width;
} else {
// Columns; Right to left
imin = f.width - 1;
}
if (cbVDir.SelectedIndex == 0) {
// Columns; Top to bottom
jmax = f.height;
} else {
// Columns; Bottom to top
jmin = f.height - 1;
}
} else {
if (cbVDir.SelectedIndex == 0) {
// Rows; Left to right
imax = f.height;
} else {
// Rows; Right to left
imin = f.height - 1;
}
if (cbHDir.SelectedIndex == 0) {
// Rows; Top to bottom
jmax = f.width;
} else {
// Rows; Bottom to top
jmin = f.width - 1;
}
}
}
for (int i = imin; i != imax; i += idir) { for (int i = imin; i != imax; i += idir) {
if (lines == 0) { if (lines == 0) {
// "Column/Row per line" - new line offset // "Column/Row per line" - new line offset
@@ -257,21 +328,33 @@ namespace McBitFont {
// count posted numbers // count posted numbers
numcount++; numcount++;
if (lines == 2 && numcount >= lineslim && !(j + jdir == jmax && i + idir == imax)) {
// "X numbers per line" - line break
numcount = 0;
output += ",\n ";
}
} }
} }
if (lines == 0) { if (lines == 0) {
// "Column/Row per line" - closing line // "Column/Row per line" - closing line
output += cbracket + (i+idir!=imax ? "," : "") + "\n"; output += cbracket + ((i+idir==imax) && f.Equals(flast) ? "" : ",") + "\n";
} }
} }
if (lines == 1) { if (lines == 1) {
// "1 symbol per line" - closing line // "1 symbol per line" - closing line
if (com) { if (!f.Equals(flast)) output += ",";
if (com && fcount > 1) {
//...with a comment //...with a comment
output += " // " + f.code.ToString() + " --> " + mainForm.decodeSymbol(f.code); output += " // " + f.code.ToString() + " --> " + mainForm.decodeSymbol(f.code);
} }
output += "\n"; output += "\n";
} }
if (lines == 2) {
// "X numbers per line" - closing line
if (!f.Equals(flast)) output += ",";
output += "\n";
numcount = 0;
}
} }
// Close array definition // Close array definition
output += "};\n"; output += "};\n";
@@ -286,6 +369,10 @@ namespace McBitFont {
MessageBox.Show("Cannot pack the font meta header into 2D array!\nChoose 1D array or disable the meta header.\n(Setting array format to 1D array)", "No header in 2D array!", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Cannot pack the font meta header into 2D array!\nChoose 1D array or disable the meta header.\n(Setting array format to 1D array)", "No header in 2D array!", MessageBoxButtons.OK, MessageBoxIcon.Information);
cbFormat.SelectedIndex = 0; cbFormat.SelectedIndex = 0;
} }
if (!mainForm.monospaced && cbFormat.SelectedIndex == 1 && mainForm.frames.Count > 1) {
MessageBox.Show("Cannot pack the variable width font into 2D array!\n(Setting array format to 1D array)", "2D arrays are for monospaced fonts only!", MessageBoxButtons.OK, MessageBoxIcon.Information);
cbFormat.SelectedIndex = 0;
}
if (cbFormat.SelectedIndex == 1) { if (cbFormat.SelectedIndex == 1) {
cbLines.SelectedIndex = 0; cbLines.SelectedIndex = 0;
cbLines.Enabled = false; cbLines.Enabled = false;
@@ -293,5 +380,15 @@ namespace McBitFont {
cbLines.Enabled = true; cbLines.Enabled = true;
} }
} }
private void cbLines_SelectedIndexChanged(object sender, EventArgs e) {
if (cbLines.SelectedIndex == 2) {
nudXLines.Enabled = true;
lblXLines.Enabled = true;
} else {
nudXLines.Enabled = false;
lblXLines.Enabled = false;
}
}
} }
} }

View File

@@ -55,8 +55,8 @@
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.addSymbolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeSymbolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removeSymbolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.applyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shiftUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shiftUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shiftDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shiftDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -65,11 +65,12 @@
this.invertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.invertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mirrorXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mirrorXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mirrorYToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mirrorYToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dlgSave = new System.Windows.Forms.SaveFileDialog(); this.dlgSave = new System.Windows.Forms.SaveFileDialog();
this.dlgOpen = new System.Windows.Forms.OpenFileDialog(); this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
this.applyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.prependSymbolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.appendSymbolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
@@ -324,6 +325,7 @@
this.miniList.ShowGroups = false; this.miniList.ShowGroups = false;
this.miniList.Size = new System.Drawing.Size(343, 395); this.miniList.Size = new System.Drawing.Size(343, 395);
this.miniList.SmallImageList = this.ilMiniatures; this.miniList.SmallImageList = this.ilMiniatures;
this.miniList.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.miniList.TabIndex = 12; this.miniList.TabIndex = 12;
this.miniList.TabStop = false; this.miniList.TabStop = false;
this.miniList.TileSize = new System.Drawing.Size(50, 50); this.miniList.TileSize = new System.Drawing.Size(50, 50);
@@ -407,7 +409,9 @@
// //
this.newToolStripMenuItem.Image = global::McBitFont.Properties.Resources.file; this.newToolStripMenuItem.Image = global::McBitFont.Properties.Resources.file;
this.newToolStripMenuItem.Name = "newToolStripMenuItem"; this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(112, 22); this.newToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+N";
this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.newToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.newToolStripMenuItem.Text = "New"; this.newToolStripMenuItem.Text = "New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
// //
@@ -415,7 +419,9 @@
// //
this.openToolStripMenuItem.Image = global::McBitFont.Properties.Resources.folder_open; this.openToolStripMenuItem.Image = global::McBitFont.Properties.Resources.folder_open;
this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(112, 22); this.openToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+O";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.openToolStripMenuItem.Text = "Open"; this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
// //
@@ -423,35 +429,30 @@
// //
this.saveToolStripMenuItem.Image = global::McBitFont.Properties.Resources.save; this.saveToolStripMenuItem.Image = global::McBitFont.Properties.Resources.save;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(112, 22); this.saveToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+S";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveToolStripMenuItem.Text = "Save as"; this.saveToolStripMenuItem.Text = "Save as";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
// //
// exitToolStripMenuItem // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(112, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
// //
// editToolStripMenuItem // editToolStripMenuItem
// //
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addSymbolToolStripMenuItem, this.prependSymbolToolStripMenuItem,
this.appendSymbolToolStripMenuItem,
this.removeSymbolToolStripMenuItem, this.removeSymbolToolStripMenuItem,
this.applyToolStripMenuItem}); this.applyToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "Edit"; this.editToolStripMenuItem.Text = "Edit";
// //
// addSymbolToolStripMenuItem
//
this.addSymbolToolStripMenuItem.Enabled = false;
this.addSymbolToolStripMenuItem.Image = global::McBitFont.Properties.Resources.action_add;
this.addSymbolToolStripMenuItem.Name = "addSymbolToolStripMenuItem";
this.addSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.addSymbolToolStripMenuItem.Text = "Add symbol";
//
// removeSymbolToolStripMenuItem // removeSymbolToolStripMenuItem
// //
this.removeSymbolToolStripMenuItem.Enabled = false; this.removeSymbolToolStripMenuItem.Enabled = false;
@@ -459,6 +460,14 @@
this.removeSymbolToolStripMenuItem.Name = "removeSymbolToolStripMenuItem"; this.removeSymbolToolStripMenuItem.Name = "removeSymbolToolStripMenuItem";
this.removeSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.removeSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.removeSymbolToolStripMenuItem.Text = "Remove symbol"; this.removeSymbolToolStripMenuItem.Text = "Remove symbol";
this.removeSymbolToolStripMenuItem.Click += new System.EventHandler(this.removeSymbolToolStripMenuItem_Click);
//
// applyToolStripMenuItem
//
this.applyToolStripMenuItem.Name = "applyToolStripMenuItem";
this.applyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.applyToolStripMenuItem.Text = "Apply";
this.applyToolStripMenuItem.Click += new System.EventHandler(this.button2_Click);
// //
// toolsToolStripMenuItem // toolsToolStripMenuItem
// //
@@ -479,7 +488,9 @@
// //
this.shiftUpToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_top; this.shiftUpToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_top;
this.shiftUpToolStripMenuItem.Name = "shiftUpToolStripMenuItem"; this.shiftUpToolStripMenuItem.Name = "shiftUpToolStripMenuItem";
this.shiftUpToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.shiftUpToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Up";
this.shiftUpToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up)));
this.shiftUpToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.shiftUpToolStripMenuItem.Text = "Shift Up"; this.shiftUpToolStripMenuItem.Text = "Shift Up";
this.shiftUpToolStripMenuItem.Click += new System.EventHandler(this.btnShiftUp_Click); this.shiftUpToolStripMenuItem.Click += new System.EventHandler(this.btnShiftUp_Click);
// //
@@ -487,7 +498,9 @@
// //
this.shiftDownToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_down; this.shiftDownToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_down;
this.shiftDownToolStripMenuItem.Name = "shiftDownToolStripMenuItem"; this.shiftDownToolStripMenuItem.Name = "shiftDownToolStripMenuItem";
this.shiftDownToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.shiftDownToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Down";
this.shiftDownToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down)));
this.shiftDownToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.shiftDownToolStripMenuItem.Text = "Shift Down"; this.shiftDownToolStripMenuItem.Text = "Shift Down";
this.shiftDownToolStripMenuItem.Click += new System.EventHandler(this.btnShiftDown_Click); this.shiftDownToolStripMenuItem.Click += new System.EventHandler(this.btnShiftDown_Click);
// //
@@ -495,7 +508,9 @@
// //
this.shiftLeftToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_back; this.shiftLeftToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_back;
this.shiftLeftToolStripMenuItem.Name = "shiftLeftToolStripMenuItem"; this.shiftLeftToolStripMenuItem.Name = "shiftLeftToolStripMenuItem";
this.shiftLeftToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.shiftLeftToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Left";
this.shiftLeftToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Left)));
this.shiftLeftToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.shiftLeftToolStripMenuItem.Text = "Shift left"; this.shiftLeftToolStripMenuItem.Text = "Shift left";
this.shiftLeftToolStripMenuItem.Click += new System.EventHandler(this.btnShiftLeft_Click); this.shiftLeftToolStripMenuItem.Click += new System.EventHandler(this.btnShiftLeft_Click);
// //
@@ -503,31 +518,48 @@
// //
this.shiftRightToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_next; this.shiftRightToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_next;
this.shiftRightToolStripMenuItem.Name = "shiftRightToolStripMenuItem"; this.shiftRightToolStripMenuItem.Name = "shiftRightToolStripMenuItem";
this.shiftRightToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.shiftRightToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Right";
this.shiftRightToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Right)));
this.shiftRightToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.shiftRightToolStripMenuItem.Text = "Shift Right"; this.shiftRightToolStripMenuItem.Text = "Shift Right";
this.shiftRightToolStripMenuItem.Click += new System.EventHandler(this.btnShiftRight_Click); this.shiftRightToolStripMenuItem.Click += new System.EventHandler(this.btnShiftRight_Click);
// //
// invertToolStripMenuItem // invertToolStripMenuItem
// //
this.invertToolStripMenuItem.Name = "invertToolStripMenuItem"; this.invertToolStripMenuItem.Name = "invertToolStripMenuItem";
this.invertToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.invertToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+I";
this.invertToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
this.invertToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.invertToolStripMenuItem.Text = "Invert"; this.invertToolStripMenuItem.Text = "Invert";
this.invertToolStripMenuItem.Click += new System.EventHandler(this.btnInvert_Click); this.invertToolStripMenuItem.Click += new System.EventHandler(this.btnInvert_Click);
// //
// mirrorXToolStripMenuItem // mirrorXToolStripMenuItem
// //
this.mirrorXToolStripMenuItem.Name = "mirrorXToolStripMenuItem"; this.mirrorXToolStripMenuItem.Name = "mirrorXToolStripMenuItem";
this.mirrorXToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.mirrorXToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+X";
this.mirrorXToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X)));
this.mirrorXToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.mirrorXToolStripMenuItem.Text = "Mirror X"; this.mirrorXToolStripMenuItem.Text = "Mirror X";
this.mirrorXToolStripMenuItem.Click += new System.EventHandler(this.btnMirrorX_Click); this.mirrorXToolStripMenuItem.Click += new System.EventHandler(this.btnMirrorX_Click);
// //
// mirrorYToolStripMenuItem // mirrorYToolStripMenuItem
// //
this.mirrorYToolStripMenuItem.Name = "mirrorYToolStripMenuItem"; this.mirrorYToolStripMenuItem.Name = "mirrorYToolStripMenuItem";
this.mirrorYToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.mirrorYToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Y";
this.mirrorYToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
this.mirrorYToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.mirrorYToolStripMenuItem.Text = "Mirror Y"; this.mirrorYToolStripMenuItem.Text = "Mirror Y";
this.mirrorYToolStripMenuItem.Click += new System.EventHandler(this.btnMirrorY_Click); this.mirrorYToolStripMenuItem.Click += new System.EventHandler(this.btnMirrorY_Click);
// //
// exportToolStripMenuItem
//
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+E";
this.exportToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
this.exportToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.exportToolStripMenuItem.Text = "Export";
this.exportToolStripMenuItem.Click += new System.EventHandler(this.button1_Click);
//
// aboutToolStripMenuItem // aboutToolStripMenuItem
// //
this.aboutToolStripMenuItem.Enabled = false; this.aboutToolStripMenuItem.Enabled = false;
@@ -545,19 +577,23 @@
this.dlgOpen.DefaultExt = "mbf"; this.dlgOpen.DefaultExt = "mbf";
this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*"; this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*";
// //
// applyToolStripMenuItem // prependSymbolToolStripMenuItem
// //
this.applyToolStripMenuItem.Name = "applyToolStripMenuItem"; this.prependSymbolToolStripMenuItem.Enabled = false;
this.applyToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.prependSymbolToolStripMenuItem.Image = global::McBitFont.Properties.Resources.action_add;
this.applyToolStripMenuItem.Text = "Apply"; this.prependSymbolToolStripMenuItem.Name = "prependSymbolToolStripMenuItem";
this.applyToolStripMenuItem.Click += new System.EventHandler(this.button2_Click); this.prependSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.prependSymbolToolStripMenuItem.Text = "Prepend symbol";
this.prependSymbolToolStripMenuItem.Click += new System.EventHandler(this.prependSymbolToolStripMenuItem_Click);
// //
// exportToolStripMenuItem // appendSymbolToolStripMenuItem
// //
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; this.appendSymbolToolStripMenuItem.Enabled = false;
this.exportToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.appendSymbolToolStripMenuItem.Image = global::McBitFont.Properties.Resources.action_add;
this.exportToolStripMenuItem.Text = "Export"; this.appendSymbolToolStripMenuItem.Name = "appendSymbolToolStripMenuItem";
this.exportToolStripMenuItem.Click += new System.EventHandler(this.button1_Click); this.appendSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.appendSymbolToolStripMenuItem.Text = "Append symbol";
this.appendSymbolToolStripMenuItem.Click += new System.EventHandler(this.prependSymbolToolStripMenuItem_Click);
// //
// MainForm // MainForm
// //
@@ -630,7 +666,6 @@
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem addSymbolToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeSymbolToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeSymbolToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem shiftUpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem shiftUpToolStripMenuItem;
@@ -645,6 +680,8 @@
private System.Windows.Forms.OpenFileDialog dlgOpen; private System.Windows.Forms.OpenFileDialog dlgOpen;
private System.Windows.Forms.ToolStripMenuItem applyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem applyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem prependSymbolToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem appendSymbolToolStripMenuItem;
} }
} }

View File

@@ -46,7 +46,7 @@ namespace McBitFont {
private int pixelOffset = 5; private int pixelOffset = 5;
private int gap; private int gap;
private int w, h; private int w, h;
bool monospaced = false; public bool monospaced = false;
bool modified = false; bool modified = false;
bool prjModified = false; bool prjModified = false;
public const string version = "1.0"; public const string version = "1.0";
@@ -138,6 +138,8 @@ namespace McBitFont {
ilMiniatures.Images.Add(s, (Image)bmp); ilMiniatures.Images.Add(s, (Image)bmp);
miniList.Items[s].ImageKey = s; miniList.Items[s].ImageKey = s;
} }
} else {
if (nudX.Focused) modified = true;
} }
prjModified = true; prjModified = true;
dotResize((int)nudX.Value, dotHeight); dotResize((int)nudX.Value, dotHeight);
@@ -389,7 +391,7 @@ namespace McBitFont {
frames[index] = f; frames[index] = f;
var sizedBMP = getMiniPictue(f); var sizedBMP = getMiniPictue(f);
string s = f.code.ToString(); string s = f.code.ToString().PadLeft(3, '0');
ilMiniatures.Images.RemoveByKey(s); ilMiniatures.Images.RemoveByKey(s);
ilMiniatures.Images.Add(s, (Image)sizedBMP); ilMiniatures.Images.Add(s, (Image)sizedBMP);
sizedBMP.Dispose(); sizedBMP.Dispose();
@@ -490,7 +492,7 @@ namespace McBitFont {
} }
lblType.Text = monospaced ? "Monospaced" : "Variable width / Single"; lblType.Text = monospaced ? "Monospaced" : "Variable width / Single";
foreach (FrameMiniature ff in frames) { foreach (FrameMiniature ff in frames) {
var s = ff.code.ToString(); var s = ff.code.ToString().PadLeft(3, '0');
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff)); ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
codepage =(form.cbEncoding.SelectedItem as New.EncodingItem).Code; codepage =(form.cbEncoding.SelectedItem as New.EncodingItem).Code;
var sss = decodeSymbol(ff.code); var sss = decodeSymbol(ff.code);
@@ -503,6 +505,8 @@ namespace McBitFont {
prjName = "Untitled"; prjName = "Untitled";
this.Text = "McBitFont " + version + " - " + prjName; this.Text = "McBitFont " + version + " - " + prjName;
modified = false;
checkForAdd();
} }
} }
@@ -515,7 +519,9 @@ namespace McBitFont {
modified = false; modified = false;
} }
if (miniList.SelectedItems.Count == 0) { if (miniList.SelectedItems.Count == 0) {
miniList.Items[0].Selected = true; removeSymbolToolStripMenuItem.Enabled = false;
return;
//miniList.Items[0].Selected = true;
} }
var sel = miniList.SelectedItems[0]; var sel = miniList.SelectedItems[0];
int code = Convert.ToInt32(sel.ImageKey); int code = Convert.ToInt32(sel.ImageKey);
@@ -524,6 +530,12 @@ namespace McBitFont {
nudY.Value = ff.height; nudY.Value = ff.height;
f = ff; f = ff;
dotPanel.Refresh(); dotPanel.Refresh();
ff = frames.Find(x => x.code == code);
if (frames.Count > 1 && (ff.Equals(frames.First()) || ff.Equals(frames.Last()))) {
removeSymbolToolStripMenuItem.Enabled = true;
} else {
removeSymbolToolStripMenuItem.Enabled = false;
}
} }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
@@ -584,6 +596,49 @@ namespace McBitFont {
prjName = Path.GetFileNameWithoutExtension(dlgOpen.FileName); prjName = Path.GetFileNameWithoutExtension(dlgOpen.FileName);
this.Text = "McBitFont " + version + " - " + prjName; this.Text = "McBitFont " + version + " - " + prjName;
checkForAdd();
}
}
private void removeSymbolToolStripMenuItem_Click(object sender, EventArgs e) {
if (miniList.SelectedItems.Count == 0) {
removeSymbolToolStripMenuItem.Enabled = false;
return;
}
var sel = miniList.SelectedItems[0].ImageKey;
int code = Convert.ToInt32(miniList.SelectedItems[0].ImageKey);
FrameMiniature ff = frames.Find(x => x.code == code);
frames.Remove(ff);
miniList.SelectedItems[0].Remove();
//miniList.Items[0].Selected = true;
}
private void prependSymbolToolStripMenuItem_Click(object sender, EventArgs e) {
FrameMiniature ff;
if (sender == prependSymbolToolStripMenuItem) {
ff = new FrameMiniature(frames.First().code - 1, dotWidth, dotHeight);
frames.Insert(0, ff);
} else {
ff = new FrameMiniature(frames.Last().code + 1, dotWidth, dotHeight);
frames.Add(ff);
}
var s = ff.code.ToString().PadLeft(3, '0');
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
var sss = decodeSymbol(ff.code);
miniList.Items.Add(s, s + ' ' + sss, s);
checkForAdd();
}
private void checkForAdd() {
if (frames.Count > 1) {
if (frames.First().code > 0) prependSymbolToolStripMenuItem.Enabled = true;
else prependSymbolToolStripMenuItem.Enabled = false;
if (frames.Last().code < 255) appendSymbolToolStripMenuItem.Enabled = true;
else appendSymbolToolStripMenuItem.Enabled = false;
} else {
prependSymbolToolStripMenuItem.Enabled = false;
appendSymbolToolStripMenuItem.Enabled = false;
} }
} }

BIN
icons_9x9.mbf Normal file

Binary file not shown.