Characters Encoding management

This commit is contained in:
Anton Mukhin
2023-05-10 13:39:59 +03:00
parent e927b2685d
commit 54ade42409
3 changed files with 65 additions and 19 deletions

View File

@@ -479,13 +479,13 @@ namespace McBitFont {
} }
} }
monospaced = form.rbMono.Checked; monospaced = form.rbMono.Checked;
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();
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff)); ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
var sss = s + ' ' + append + (char)(ff.code); var enc = Encoding.GetEncoding((form.cbEncoding.SelectedItem as New.EncodingItem).Code);
//byte[] aaa = { (byte)ff.code} var sss = enc.GetString(new byte[] { (byte)ff.code });
//Debug.WriteLine(sss.ToString() + Encoding.UTF8.GetString(new byte[] { 0x10, 0x04 })); miniList.Items.Add(s, s+' '+append+sss, s);
miniList.Items.Add(s, s+' '+append+(char)(ff.code), s);
} }
nudX.Value =neww; nudX.Value =neww;
nudY.Value = newh; nudY.Value = newh;

View File

@@ -37,13 +37,14 @@
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.cbSingle = new System.Windows.Forms.CheckBox(); this.cbSingle = new System.Windows.Forms.CheckBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.cbEncoding = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.nudNewX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudNewX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudNewY)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudNewY)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// nudNewX // nudNewX
// //
this.nudNewX.Location = new System.Drawing.Point(74, 11); this.nudNewX.Location = new System.Drawing.Point(74, 19);
this.nudNewX.Maximum = new decimal(new int[] { this.nudNewX.Maximum = new decimal(new int[] {
255, 255,
0, 0,
@@ -66,7 +67,7 @@
// //
// nudNewY // nudNewY
// //
this.nudNewY.Location = new System.Drawing.Point(74, 37); this.nudNewY.Location = new System.Drawing.Point(74, 45);
this.nudNewY.Maximum = new decimal(new int[] { this.nudNewY.Maximum = new decimal(new int[] {
255, 255,
0, 0,
@@ -90,7 +91,7 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(30, 13); this.label1.Location = new System.Drawing.Point(30, 21);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(38, 13); this.label1.Size = new System.Drawing.Size(38, 13);
this.label1.TabIndex = 2; this.label1.TabIndex = 2;
@@ -100,7 +101,7 @@
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(27, 39); this.label2.Location = new System.Drawing.Point(27, 47);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 13); this.label2.Size = new System.Drawing.Size(41, 13);
this.label2.TabIndex = 3; this.label2.TabIndex = 3;
@@ -111,7 +112,7 @@
// //
this.rbMono.AutoSize = true; this.rbMono.AutoSize = true;
this.rbMono.Checked = true; this.rbMono.Checked = true;
this.rbMono.Location = new System.Drawing.Point(30, 63); this.rbMono.Location = new System.Drawing.Point(30, 71);
this.rbMono.Name = "rbMono"; this.rbMono.Name = "rbMono";
this.rbMono.Size = new System.Drawing.Size(81, 17); this.rbMono.Size = new System.Drawing.Size(81, 17);
this.rbMono.TabIndex = 4; this.rbMono.TabIndex = 4;
@@ -122,7 +123,7 @@
// rbVar // rbVar
// //
this.rbVar.AutoSize = true; this.rbVar.AutoSize = true;
this.rbVar.Location = new System.Drawing.Point(30, 86); this.rbVar.Location = new System.Drawing.Point(30, 94);
this.rbVar.Name = "rbVar"; this.rbVar.Name = "rbVar";
this.rbVar.Size = new System.Drawing.Size(91, 17); this.rbVar.Size = new System.Drawing.Size(91, 17);
this.rbVar.TabIndex = 5; this.rbVar.TabIndex = 5;
@@ -132,7 +133,7 @@
// cbNotPrintable // cbNotPrintable
// //
this.cbNotPrintable.AutoSize = true; this.cbNotPrintable.AutoSize = true;
this.cbNotPrintable.Location = new System.Drawing.Point(146, 38); this.cbNotPrintable.Location = new System.Drawing.Point(146, 35);
this.cbNotPrintable.Name = "cbNotPrintable"; this.cbNotPrintable.Name = "cbNotPrintable";
this.cbNotPrintable.Size = new System.Drawing.Size(116, 17); this.cbNotPrintable.Size = new System.Drawing.Size(116, 17);
this.cbNotPrintable.TabIndex = 7; this.cbNotPrintable.TabIndex = 7;
@@ -144,7 +145,7 @@
this.cbLatin.AutoSize = true; this.cbLatin.AutoSize = true;
this.cbLatin.Checked = true; this.cbLatin.Checked = true;
this.cbLatin.CheckState = System.Windows.Forms.CheckState.Checked; this.cbLatin.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbLatin.Location = new System.Drawing.Point(146, 61); this.cbLatin.Location = new System.Drawing.Point(146, 58);
this.cbLatin.Name = "cbLatin"; this.cbLatin.Name = "cbLatin";
this.cbLatin.Size = new System.Drawing.Size(91, 17); this.cbLatin.Size = new System.Drawing.Size(91, 17);
this.cbLatin.TabIndex = 8; this.cbLatin.TabIndex = 8;
@@ -154,16 +155,17 @@
// cbExtended // cbExtended
// //
this.cbExtended.AutoSize = true; this.cbExtended.AutoSize = true;
this.cbExtended.Location = new System.Drawing.Point(146, 84); this.cbExtended.Location = new System.Drawing.Point(146, 81);
this.cbExtended.Name = "cbExtended"; this.cbExtended.Name = "cbExtended";
this.cbExtended.Size = new System.Drawing.Size(119, 17); this.cbExtended.Size = new System.Drawing.Size(119, 17);
this.cbExtended.TabIndex = 9; this.cbExtended.TabIndex = 9;
this.cbExtended.Text = "128-255 (Extended)"; this.cbExtended.Text = "128-255 (Extended)";
this.cbExtended.UseVisualStyleBackColor = true; this.cbExtended.UseVisualStyleBackColor = true;
this.cbExtended.CheckedChanged += new System.EventHandler(this.cbExtended_CheckedChanged);
// //
// btnOK // btnOK
// //
this.btnOK.Location = new System.Drawing.Point(56, 121); this.btnOK.Location = new System.Drawing.Point(56, 143);
this.btnOK.Name = "btnOK"; this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23); this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 10; this.btnOK.TabIndex = 10;
@@ -173,7 +175,8 @@
// //
// btnCancel // btnCancel
// //
this.btnCancel.Location = new System.Drawing.Point(165, 121); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(165, 143);
this.btnCancel.Name = "btnCancel"; this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 11; this.btnCancel.TabIndex = 11;
@@ -184,7 +187,7 @@
// cbSingle // cbSingle
// //
this.cbSingle.AutoSize = true; this.cbSingle.AutoSize = true;
this.cbSingle.Location = new System.Drawing.Point(146, 15); this.cbSingle.Location = new System.Drawing.Point(146, 12);
this.cbSingle.Name = "cbSingle"; this.cbSingle.Name = "cbSingle";
this.cbSingle.Size = new System.Drawing.Size(84, 17); this.cbSingle.Size = new System.Drawing.Size(84, 17);
this.cbSingle.TabIndex = 12; this.cbSingle.TabIndex = 12;
@@ -199,12 +202,23 @@
this.toolTip1.ReshowDelay = 100; this.toolTip1.ReshowDelay = 100;
this.toolTip1.ToolTipTitle = "Info"; this.toolTip1.ToolTipTitle = "Info";
// //
// cbEncoding
//
this.cbEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbEncoding.Enabled = false;
this.cbEncoding.FormattingEnabled = true;
this.cbEncoding.Location = new System.Drawing.Point(146, 104);
this.cbEncoding.Name = "cbEncoding";
this.cbEncoding.Size = new System.Drawing.Size(121, 21);
this.cbEncoding.TabIndex = 13;
//
// New // New
// //
this.AcceptButton = this.btnOK; this.AcceptButton = this.btnOK;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.btnCancel; this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(284, 161); this.ClientSize = new System.Drawing.Size(284, 181);
this.Controls.Add(this.cbEncoding);
this.Controls.Add(this.cbSingle); this.Controls.Add(this.cbSingle);
this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK); this.Controls.Add(this.btnOK);
@@ -219,9 +233,9 @@
this.Controls.Add(this.nudNewX); this.Controls.Add(this.nudNewX);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(300, 200); this.MaximumSize = new System.Drawing.Size(300, 220);
this.MinimizeBox = false; this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(300, 200); this.MinimumSize = new System.Drawing.Size(300, 220);
this.Name = "New"; this.Name = "New";
this.ShowIcon = false; this.ShowIcon = false;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
@@ -250,5 +264,6 @@
private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnCancel;
public System.Windows.Forms.CheckBox cbSingle; public System.Windows.Forms.CheckBox cbSingle;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
public System.Windows.Forms.ComboBox cbEncoding;
} }
} }

View File

@@ -10,6 +10,22 @@ using System.Windows.Forms;
namespace McBitFont { namespace McBitFont {
public partial class New : Form { public partial class New : Form {
public class EncodingItem {
public string Text { get; set; }
public int Code { get; set; }
public EncodingItem(int code, string text) {
Code = code;
Text = text;
}
public override string ToString() {
return Text;
}
}
public New() { public New() {
InitializeComponent(); InitializeComponent();
} }
@@ -32,6 +48,17 @@ namespace McBitFont {
toolTip1.SetToolTip(cbNotPrintable, "Add not printable characters with codes 0 - 31"); toolTip1.SetToolTip(cbNotPrintable, "Add not printable characters with codes 0 - 31");
toolTip1.SetToolTip(cbLatin, "Add Latin characters with codes 32 - 127"); toolTip1.SetToolTip(cbLatin, "Add Latin characters with codes 32 - 127");
toolTip1.SetToolTip(cbExtended, "Add Extended characters with codes 128 - 255"); toolTip1.SetToolTip(cbExtended, "Add Extended characters with codes 128 - 255");
cbEncoding.Items.Clear();
cbEncoding.Items.Add(new EncodingItem(1250, "Central European"));
cbEncoding.Items.Add(new EncodingItem(1251, "Cyrillic"));
cbEncoding.Items.Add(new EncodingItem(1252, "Western European"));
cbEncoding.Items.Add(new EncodingItem(1253, "Greek"));
cbEncoding.Items.Add(new EncodingItem(1254, "Turkish"));
cbEncoding.Items.Add(new EncodingItem(1255, "Hebrew"));
cbEncoding.Items.Add(new EncodingItem(1256, "Arabic"));
cbEncoding.Items.Add(new EncodingItem(1257, "Baltic"));
cbEncoding.SelectedIndex = 1;
} }
private void btnCancel_Click(object sender, EventArgs e) { private void btnCancel_Click(object sender, EventArgs e) {
@@ -47,5 +74,9 @@ namespace McBitFont {
nud.Select(0, nud.Text.Length); nud.Select(0, nud.Text.Length);
} }
private void cbExtended_CheckedChanged(object sender, EventArgs e) {
cbEncoding.Enabled = cbExtended.Checked;
}
} }
} }