Basic export text generation done.

This commit is contained in:
Anton Mukhin
2023-05-10 18:23:57 +03:00
parent 54ade42409
commit 04bace7267
4 changed files with 290 additions and 143 deletions

View File

@@ -25,23 +25,24 @@
private void InitializeComponent() { private void InitializeComponent() {
this.txtOutput = new System.Windows.Forms.RichTextBox(); this.txtOutput = new System.Windows.Forms.RichTextBox();
this.gbScan = new System.Windows.Forms.GroupBox(); this.gbScan = new System.Windows.Forms.GroupBox();
this.gbOptions = new System.Windows.Forms.GroupBox();
this.cbComments = new System.Windows.Forms.CheckBox();
this.cbHeader = new System.Windows.Forms.CheckBox();
this.cbOrder = new System.Windows.Forms.ComboBox();
this.cbHDir = new System.Windows.Forms.ComboBox();
this.cbVDir = new System.Windows.Forms.ComboBox(); this.cbVDir = new System.Windows.Forms.ComboBox();
this.cbHDir = new System.Windows.Forms.ComboBox();
this.cbOrder = new System.Windows.Forms.ComboBox();
this.gbOptions = new System.Windows.Forms.GroupBox();
this.cbHeader = new System.Windows.Forms.CheckBox();
this.cbComments = new System.Windows.Forms.CheckBox();
this.gbNumbers = new System.Windows.Forms.GroupBox(); this.gbNumbers = new System.Windows.Forms.GroupBox();
this.cbNumBase = new System.Windows.Forms.ComboBox();
this.cbNumSize = new System.Windows.Forms.ComboBox();
this.cbBitOrder = new System.Windows.Forms.ComboBox(); this.cbBitOrder = new System.Windows.Forms.ComboBox();
this.cbNumSize = 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.cbFormat = new System.Windows.Forms.ComboBox();
this.cbLines = new System.Windows.Forms.ComboBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.cbLines = 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();
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.cbZeroes = new System.Windows.Forms.CheckBox();
this.gbScan.SuspendLayout(); this.gbScan.SuspendLayout();
this.gbOptions.SuspendLayout(); this.gbOptions.SuspendLayout();
this.gbNumbers.SuspendLayout(); this.gbNumbers.SuspendLayout();
@@ -62,7 +63,7 @@
this.txtOutput.Location = new System.Drawing.Point(151, 12); this.txtOutput.Location = new System.Drawing.Point(151, 12);
this.txtOutput.Name = "txtOutput"; this.txtOutput.Name = "txtOutput";
this.txtOutput.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; this.txtOutput.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.txtOutput.Size = new System.Drawing.Size(529, 482); this.txtOutput.Size = new System.Drawing.Size(529, 507);
this.txtOutput.TabIndex = 0; this.txtOutput.TabIndex = 0;
this.txtOutput.Text = "// Comment.\nusing System;\n\npublic class Stuff : Form { \n public static void Main(" + this.txtOutput.Text = "// Comment.\nusing System;\n\npublic class Stuff : Form { \n public static void Main(" +
"String args) {\n }\n}\n\n\nTest\n123123\nCode code code\n\nAAAsdasdasd\n!"; "String args) {\n }\n}\n\n\nTest\n123123\nCode code code\n\nAAAsdasdasd\n!";
@@ -79,40 +80,29 @@
this.gbScan.TabStop = false; this.gbScan.TabStop = false;
this.gbScan.Text = "Scan"; this.gbScan.Text = "Scan";
// //
// gbOptions // cbVDir
// //
this.gbOptions.Controls.Add(this.cbHeader); this.cbVDir.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.gbOptions.Controls.Add(this.cbComments); this.cbVDir.FormattingEnabled = true;
this.gbOptions.Location = new System.Drawing.Point(5, 345); this.cbVDir.Items.AddRange(new object[] {
this.gbOptions.Name = "gbOptions"; "Top to Bottom",
this.gbOptions.Size = new System.Drawing.Size(140, 65); "Bottom to Top"});
this.gbOptions.TabIndex = 3; this.cbVDir.Location = new System.Drawing.Point(10, 73);
this.gbOptions.TabStop = false; this.cbVDir.Name = "cbVDir";
this.gbOptions.Text = "Options"; this.cbVDir.Size = new System.Drawing.Size(121, 21);
this.cbVDir.TabIndex = 2;
// //
// cbComments // cbHDir
// //
this.cbComments.AutoSize = true; this.cbHDir.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbComments.Checked = true; this.cbHDir.FormattingEnabled = true;
this.cbComments.CheckState = System.Windows.Forms.CheckState.Checked; this.cbHDir.Items.AddRange(new object[] {
this.cbComments.Location = new System.Drawing.Point(6, 42); "Left to Right",
this.cbComments.Name = "cbComments"; "Right to Left"});
this.cbComments.Size = new System.Drawing.Size(75, 17); this.cbHDir.Location = new System.Drawing.Point(10, 46);
this.cbComments.TabIndex = 0; this.cbHDir.Name = "cbHDir";
this.cbComments.Text = "Comments"; this.cbHDir.Size = new System.Drawing.Size(121, 21);
this.cbComments.UseVisualStyleBackColor = true; this.cbHDir.TabIndex = 1;
//
// cbHeader
//
this.cbHeader.AutoSize = true;
this.cbHeader.Checked = true;
this.cbHeader.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbHeader.Location = new System.Drawing.Point(6, 19);
this.cbHeader.Name = "cbHeader";
this.cbHeader.Size = new System.Drawing.Size(86, 17);
this.cbHeader.TabIndex = 1;
this.cbHeader.Text = "Meta header";
this.cbHeader.UseVisualStyleBackColor = true;
// //
// cbOrder // cbOrder
// //
@@ -127,29 +117,41 @@
this.cbOrder.TabIndex = 0; this.cbOrder.TabIndex = 0;
this.cbOrder.SelectedIndexChanged += new System.EventHandler(this.cbOrder_SelectedIndexChanged); this.cbOrder.SelectedIndexChanged += new System.EventHandler(this.cbOrder_SelectedIndexChanged);
// //
// cbHDir // gbOptions
// //
this.cbHDir.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.gbOptions.Controls.Add(this.cbZeroes);
this.cbHDir.FormattingEnabled = true; this.gbOptions.Controls.Add(this.cbHeader);
this.cbHDir.Items.AddRange(new object[] { this.gbOptions.Controls.Add(this.cbComments);
"Left to Right", this.gbOptions.Location = new System.Drawing.Point(5, 345);
"Right to Left"}); this.gbOptions.Name = "gbOptions";
this.cbHDir.Location = new System.Drawing.Point(10, 46); this.gbOptions.Size = new System.Drawing.Size(140, 88);
this.cbHDir.Name = "cbHDir"; this.gbOptions.TabIndex = 3;
this.cbHDir.Size = new System.Drawing.Size(121, 21); this.gbOptions.TabStop = false;
this.cbHDir.TabIndex = 1; this.gbOptions.Text = "Options";
// //
// cbVDir // cbHeader
// //
this.cbVDir.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbHeader.AutoSize = true;
this.cbVDir.FormattingEnabled = true; this.cbHeader.Checked = true;
this.cbVDir.Items.AddRange(new object[] { this.cbHeader.CheckState = System.Windows.Forms.CheckState.Checked;
"Top to Bottom", this.cbHeader.Location = new System.Drawing.Point(6, 19);
"Bottom to Top"}); this.cbHeader.Name = "cbHeader";
this.cbVDir.Location = new System.Drawing.Point(10, 73); this.cbHeader.Size = new System.Drawing.Size(86, 17);
this.cbVDir.Name = "cbVDir"; this.cbHeader.TabIndex = 1;
this.cbVDir.Size = new System.Drawing.Size(121, 21); this.cbHeader.Text = "Meta header";
this.cbVDir.TabIndex = 2; this.cbHeader.UseVisualStyleBackColor = true;
//
// cbComments
//
this.cbComments.AutoSize = true;
this.cbComments.Checked = true;
this.cbComments.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbComments.Location = new System.Drawing.Point(6, 42);
this.cbComments.Name = "cbComments";
this.cbComments.Size = new System.Drawing.Size(75, 17);
this.cbComments.TabIndex = 0;
this.cbComments.Text = "Comments";
this.cbComments.UseVisualStyleBackColor = true;
// //
// gbNumbers // gbNumbers
// //
@@ -163,18 +165,17 @@
this.gbNumbers.TabStop = false; this.gbNumbers.TabStop = false;
this.gbNumbers.Text = "Numbers"; this.gbNumbers.Text = "Numbers";
// //
// cbNumBase // cbBitOrder
// //
this.cbNumBase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbBitOrder.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbNumBase.FormattingEnabled = true; this.cbBitOrder.FormattingEnabled = true;
this.cbNumBase.Items.AddRange(new object[] { this.cbBitOrder.Items.AddRange(new object[] {
"Hexadecimal", "LSB Top",
"Binary", "MSB Top"});
"Decimal"}); this.cbBitOrder.Location = new System.Drawing.Point(10, 19);
this.cbNumBase.Location = new System.Drawing.Point(10, 46); this.cbBitOrder.Name = "cbBitOrder";
this.cbNumBase.Name = "cbNumBase"; this.cbBitOrder.Size = new System.Drawing.Size(121, 21);
this.cbNumBase.Size = new System.Drawing.Size(121, 21); this.cbBitOrder.TabIndex = 5;
this.cbNumBase.TabIndex = 3;
// //
// cbNumSize // cbNumSize
// //
@@ -189,17 +190,18 @@
this.cbNumSize.Size = new System.Drawing.Size(121, 21); this.cbNumSize.Size = new System.Drawing.Size(121, 21);
this.cbNumSize.TabIndex = 4; this.cbNumSize.TabIndex = 4;
// //
// cbBitOrder // cbNumBase
// //
this.cbBitOrder.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbNumBase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbBitOrder.FormattingEnabled = true; this.cbNumBase.FormattingEnabled = true;
this.cbBitOrder.Items.AddRange(new object[] { this.cbNumBase.Items.AddRange(new object[] {
"LSB Top", "Hexadecimal",
"MSB Top"}); "Binary",
this.cbBitOrder.Location = new System.Drawing.Point(10, 19); "Decimal"});
this.cbBitOrder.Name = "cbBitOrder"; this.cbNumBase.Location = new System.Drawing.Point(10, 46);
this.cbBitOrder.Size = new System.Drawing.Size(121, 21); this.cbNumBase.Name = "cbNumBase";
this.cbBitOrder.TabIndex = 5; this.cbNumBase.Size = new System.Drawing.Size(121, 21);
this.cbNumBase.TabIndex = 3;
// //
// gbText // gbText
// //
@@ -214,31 +216,15 @@
this.gbText.TabStop = false; this.gbText.TabStop = false;
this.gbText.Text = "Text format"; this.gbText.Text = "Text format";
// //
// cbFormat // label1
// //
this.cbFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.label1.AutoSize = true;
this.cbFormat.FormattingEnabled = true; this.label1.Enabled = false;
this.cbFormat.Items.AddRange(new object[] { this.label1.Location = new System.Drawing.Point(10, 76);
"1D C array", this.label1.Name = "label1";
"2D C array", this.label1.Size = new System.Drawing.Size(60, 13);
"Comma separated"}); this.label1.TabIndex = 9;
this.cbFormat.Location = new System.Drawing.Point(10, 19); this.label1.Text = "X numbers:";
this.cbFormat.Name = "cbFormat";
this.cbFormat.Size = new System.Drawing.Size(121, 21);
this.cbFormat.TabIndex = 6;
//
// cbLines
//
this.cbLines.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbLines.FormattingEnabled = true;
this.cbLines.Items.AddRange(new object[] {
"1 Column per line",
"1 Symbol per line",
"X Numbers per line"});
this.cbLines.Location = new System.Drawing.Point(10, 46);
this.cbLines.Name = "cbLines";
this.cbLines.Size = new System.Drawing.Size(121, 21);
this.cbLines.TabIndex = 7;
// //
// numericUpDown1 // numericUpDown1
// //
@@ -263,19 +249,35 @@
0, 0,
0}); 0});
// //
// label1 // cbLines
// //
this.label1.AutoSize = true; this.cbLines.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.label1.Enabled = false; this.cbLines.FormattingEnabled = true;
this.label1.Location = new System.Drawing.Point(10, 76); this.cbLines.Items.AddRange(new object[] {
this.label1.Name = "label1"; "1 Column per line",
this.label1.Size = new System.Drawing.Size(60, 13); "1 Symbol per line",
this.label1.TabIndex = 9; "X Numbers per line"});
this.label1.Text = "X numbers:"; this.cbLines.Location = new System.Drawing.Point(10, 46);
this.cbLines.Name = "cbLines";
this.cbLines.Size = new System.Drawing.Size(121, 21);
this.cbLines.TabIndex = 7;
//
// cbFormat
//
this.cbFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbFormat.FormattingEnabled = true;
this.cbFormat.Items.AddRange(new object[] {
"1D C array",
"2D C array",
"Comma separated"});
this.cbFormat.Location = new System.Drawing.Point(10, 19);
this.cbFormat.Name = "cbFormat";
this.cbFormat.Size = new System.Drawing.Size(121, 21);
this.cbFormat.TabIndex = 6;
// //
// btnGenerate // btnGenerate
// //
this.btnGenerate.Location = new System.Drawing.Point(5, 416); this.btnGenerate.Location = new System.Drawing.Point(5, 439);
this.btnGenerate.Name = "btnGenerate"; this.btnGenerate.Name = "btnGenerate";
this.btnGenerate.Size = new System.Drawing.Size(140, 30); this.btnGenerate.Size = new System.Drawing.Size(140, 30);
this.btnGenerate.TabIndex = 6; this.btnGenerate.TabIndex = 6;
@@ -285,19 +287,32 @@
// //
// btnClose // btnClose
// //
this.btnClose.Location = new System.Drawing.Point(5, 464); this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(5, 487);
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(140, 30); this.btnClose.Size = new System.Drawing.Size(140, 30);
this.btnClose.TabIndex = 7; this.btnClose.TabIndex = 7;
this.btnClose.Text = "Close"; this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
// //
// cbZeroes
//
this.cbZeroes.AutoSize = true;
this.cbZeroes.Checked = true;
this.cbZeroes.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbZeroes.Location = new System.Drawing.Point(6, 65);
this.cbZeroes.Name = "cbZeroes";
this.cbZeroes.Size = new System.Drawing.Size(98, 17);
this.cbZeroes.TabIndex = 2;
this.cbZeroes.Text = "Leading zeroes";
this.cbZeroes.UseVisualStyleBackColor = true;
//
// Export // Export
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnClose; this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(692, 506); this.ClientSize = new System.Drawing.Size(692, 531);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnGenerate); this.Controls.Add(this.btnGenerate);
this.Controls.Add(this.gbText); this.Controls.Add(this.gbText);
@@ -305,7 +320,7 @@
this.Controls.Add(this.gbOptions); this.Controls.Add(this.gbOptions);
this.Controls.Add(this.gbScan); this.Controls.Add(this.gbScan);
this.Controls.Add(this.txtOutput); this.Controls.Add(this.txtOutput);
this.MinimumSize = new System.Drawing.Size(700, 545); this.MinimumSize = new System.Drawing.Size(700, 570);
this.Name = "Export"; this.Name = "Export";
this.ShowIcon = false; this.ShowIcon = false;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
@@ -344,5 +359,6 @@
private System.Windows.Forms.ComboBox cbFormat; private System.Windows.Forms.ComboBox cbFormat;
private System.Windows.Forms.Button btnGenerate; private System.Windows.Forms.Button btnGenerate;
private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.CheckBox cbZeroes;
} }
} }

View File

@@ -11,8 +11,13 @@ using System.Windows.Forms;
namespace McBitFont { namespace McBitFont {
public partial class Export : Form { public partial class Export : Form {
public Export() {
private MainForm mainForm;
public Export(object sender) {
InitializeComponent(); InitializeComponent();
mainForm = (MainForm)sender;
} }
private void Export_Load(object sender, EventArgs e) { private void Export_Load(object sender, EventArgs e) {
@@ -82,6 +87,133 @@ namespace McBitFont {
} }
private void btnGenerate_Click(object sender, EventArgs e) { private void btnGenerate_Click(object sender, EventArgs e) {
txtOutput.Clear();
int imin, jmin, imax, jmax, idir, jdir;
if (cbOrder.SelectedIndex == 0) {
if (cbHDir.SelectedIndex == 0) {
// Columns; Left to right
imin = 0;
imax = mainForm.dotWidth;
idir = 1;
} else {
// Columns; Right to left
imin = mainForm.dotWidth - 1;
imax = -1;
idir = -1;
}
if (cbVDir.SelectedIndex == 0) {
// Columns; Top to bottom
jmin = 0;
jmax = mainForm.dotHeight;
jdir = 1;
} else {
// Columns; Bottom to top
jmin = mainForm.dotHeight - 1;
jmax = -1;
jdir = -1;
}
} 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) {
// Rows; Top to bottom
imin = 0;
imax = mainForm.dotWidth;
idir = 1;
} else {
// Rows; Bottom to top
imin = mainForm.dotWidth - 1;
imax = -1;
idir = -1;
}
}
ushort bits = 8;
switch (cbNumSize.SelectedIndex) {
case 0:
bits = 8;
break;
case 1:
bits = 16;
break;
case 2:
bits = 32;
break;
}
int nbase = 16;
string prefix = "0x";
string pref = "";
int pad = 2;
switch (cbNumBase.SelectedIndex) {
case 0:
nbase = 16;
prefix = "0x";
pad = cbZeroes.Checked ? bits / 4 : 0;
break;
case 1:
nbase = 2;
prefix = "0b";
pad = cbZeroes.Checked ? bits : 0;
break;
case 2:
nbase = 10;
prefix = "";
pad = 0;
break;
}
foreach ( MainForm.FrameMiniature f in mainForm.frames) {
// For each frame
string str;
uint b = 0;
int t, x, y;
for (int i = imin; i != imax; i += idir) {
str = "";
for (int j = jmin; j != jmax; j += jdir) {
if (jdir < 0) t = jmin - j;
else t = j;
if (t % bits == 0) b = 0;
if (cbOrder.SelectedIndex == 0) { // Columns
x = i; y = j;
} else { // Rows
x = j; y = i;
}
if (f.data[x, y]) {
if ((cbBitOrder.SelectedIndex == 0 && jdir > 0) || (cbBitOrder.SelectedIndex == 1 && jdir < 0)) {
// LSB on top/Left
b |= (uint)(1 << (t % bits));
} else {
// MSB on top/Left
b |= (uint)(1 << (bits - (t % bits) - 1));
}
}
if (((t + 1) % bits == 0) || j + jdir == jmax) {
if (str.Length > 0) str += " ";
pref = (!cbZeroes.Checked && ((b < 10 && nbase == 16) || (b < 2 && nbase == 2))) ? "" : prefix;
str += pref + Convert.ToString(b, nbase).PadLeft(pad, '0') + ',';
}
}
txtOutput.AppendText(str);
txtOutput.AppendText(Environment.NewLine);
}
txtOutput.AppendText(Environment.NewLine);
}
txtOutput.SelectAll(); txtOutput.SelectAll();
ParseText(); ParseText();
} }

View File

@@ -313,6 +313,7 @@
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.miniList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.miniList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.miniList.GridLines = true; this.miniList.GridLines = true;
this.miniList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.miniList.HideSelection = false; this.miniList.HideSelection = false;
this.miniList.LargeImageList = this.ilMiniatures; this.miniList.LargeImageList = this.ilMiniatures;
this.miniList.Location = new System.Drawing.Point(428, 154); this.miniList.Location = new System.Drawing.Point(428, 154);

View File

@@ -39,15 +39,15 @@ namespace McBitFont {
} }
private FrameMiniature f; private FrameMiniature f;
List<FrameMiniature> frames = new List<FrameMiniature>(); public List<FrameMiniature> frames = new List<FrameMiniature>();
private int cellSize = 10; private int cellSize = 10;
private int dotWidth, dotHeight; public int dotWidth, dotHeight;
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; bool monospaced = false;
bool modified = false; bool modified = false;
bool prjModified = true; bool prjModified = false;
public MainForm() { public MainForm() {
InitializeComponent(); InitializeComponent();
@@ -70,6 +70,8 @@ namespace McBitFont {
frames.Add(new FrameMiniature(0, dotWidth, dotHeight)); frames.Add(new FrameMiniature(0, dotWidth, dotHeight));
miniList.Items.Add("0", "0 Single", "0"); miniList.Items.Add("0", "0 Single", "0");
miniList.Refresh(); miniList.Refresh();
miniList.Items[0].Selected = true;
miniList.Select();
f = copyFrame(frames.Find(x => x.code == 0)); f = copyFrame(frames.Find(x => x.code == 0));
ListViewItem_SetSpacing(miniList, 50 + 2, 50 + 22); ListViewItem_SetSpacing(miniList, 50 + 2, 50 + 22);
@@ -358,26 +360,18 @@ namespace McBitFont {
} }
private void button1_Click(object sender, EventArgs e) { private void button1_Click(object sender, EventArgs e) {
Export eform = new Export(); if (modified) {
if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
saveFrame();
} else {
f = copyFrame(frames.Find(x => x.code == f.code));
}
modified = false;
}
Export eform = new Export(this);
eform.ShowDialog(); eform.ShowDialog();
//outBox.Clear();
//String str;
//Byte b = 0;
//for (ushort i = 0; i < dotWidth; i++) {
// str = "";
// for (ushort j = 0; j < dotHeight; j++) {
// if (j % 8 == 0) b = 0;
// if (f.data[i, j]) {
// b |= (Byte)(1 << (j % 8));
// }
// if ( ((j + 1) % 8 == 0) || j+1 == dotHeight ) {
// if (str.Length > 0) str += " ";
// str += "0x" + Convert.ToString(b, 16).PadLeft(2, '0') + ',';
// }
// }
// outBox.AppendText(str);
// outBox.AppendText(Environment.NewLine);
//}
} }
private void button2_Click(object sender, EventArgs e) { private void button2_Click(object sender, EventArgs e) {
@@ -463,6 +457,7 @@ namespace McBitFont {
frames.Add( new FrameMiniature(0, neww, newh)); frames.Add( new FrameMiniature(0, neww, newh));
//f = frames.Find(x => x.code == 0); //f = frames.Find(x => x.code == 0);
append = "Single"; append = "Single";
monospaced = false;
} else { } else {
int i; int i;
if (form.cbNotPrintable.Checked) { if (form.cbNotPrintable.Checked) {
@@ -477,8 +472,8 @@ namespace McBitFont {
for (i = 128; i < 256; i++) for (i = 128; i < 256; i++)
frames.Add(new FrameMiniature(i, neww, newh)); frames.Add(new FrameMiniature(i, neww, newh));
} }
monospaced = form.rbMono.Checked;
} }
monospaced = form.rbMono.Checked;
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();
@@ -504,6 +499,9 @@ namespace McBitFont {
} }
modified = false; modified = false;
} }
if (miniList.SelectedItems.Count == 0) {
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);
FrameMiniature ff = copyFrame(frames.Find(x => x.code == code)); FrameMiniature ff = copyFrame(frames.Find(x => x.code == code));