diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs
index 08f506a..51a1194 100644
--- a/McBitFont/Form1.Designer.cs
+++ b/McBitFont/Form1.Designer.cs
@@ -1,5 +1,5 @@
namespace McBitFont {
- partial class Form1 {
+ partial class MainForm {
///
/// Обязательная переменная конструктора.
///
@@ -67,6 +67,8 @@
this.mirrorXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mirrorYToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.dlgSave = new System.Windows.Forms.SaveFileDialog();
+ this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit();
this.panel1.SuspendLayout();
@@ -413,26 +415,27 @@
// newToolStripMenuItem
//
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
- this.newToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.newToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.newToolStripMenuItem.Text = "New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
- this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.openToolStripMenuItem.Text = "Open";
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
- this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveToolStripMenuItem.Text = "Save";
+ this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
- this.exitToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
@@ -533,7 +536,18 @@
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
this.aboutToolStripMenuItem.Text = "About";
//
- // Form1
+ // dlgSave
+ //
+ this.dlgSave.DefaultExt = "mbf";
+ this.dlgSave.Filter = "McBitFont files|*.mbf|All files|*.*";
+ //
+ // dlgOpen
+ //
+ this.dlgOpen.DefaultExt = "mbf";
+ this.dlgOpen.FileName = "openFileDialog1";
+ this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*";
+ //
+ // MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -556,7 +570,7 @@
this.Controls.Add(this.dotPanel);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
- this.Name = "Form1";
+ this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "McBitFont";
this.Load += new System.EventHandler(this.Form1_Load);
@@ -615,6 +629,8 @@
private System.Windows.Forms.ToolStripMenuItem mirrorXToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mirrorYToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
+ private System.Windows.Forms.SaveFileDialog dlgSave;
+ private System.Windows.Forms.OpenFileDialog dlgOpen;
}
}
diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs
index 4ab4e71..3ba34b6 100644
--- a/McBitFont/Form1.cs
+++ b/McBitFont/Form1.cs
@@ -10,10 +10,14 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Runtime.InteropServices;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Runtime.InteropServices.ComTypes;
namespace McBitFont {
- public partial class Form1 : Form {
+ public partial class MainForm : Form {
+ [Serializable]
public struct FrameMiniature {
public FrameMiniature(int cc, int ww, int hh) {
code = cc;
@@ -27,6 +31,12 @@ namespace McBitFont {
public bool[,] data;
};
+ [Serializable]
+ public struct SaveBlock {
+ public bool monospaced;
+ public List frames;
+ }
+
private FrameMiniature f;
List frames = new List();
private int cellSize = 10;
@@ -37,7 +47,7 @@ namespace McBitFont {
bool monospaced = false;
bool modified = false;
- public Form1() {
+ public MainForm() {
InitializeComponent();
this.dotPanel.MouseWheel += new MouseEventHandler(this.dotPanel_MouseWheel);
}
@@ -401,7 +411,7 @@ namespace McBitFont {
for (i = 32; i < 128; i++)
frames.Add(new FrameMiniature(i, neww, newh));
}
- if (form.cbLatin.Checked) {
+ if (form.cbExtended.Checked) {
for (i = 128; i < 256; i++)
frames.Add(new FrameMiniature(i, neww, newh));
}
@@ -418,6 +428,7 @@ namespace McBitFont {
f = frames.First();
dotPanel.Refresh();
miniList.Refresh();
+ form.Dispose();
}
}
@@ -437,6 +448,42 @@ namespace McBitFont {
dotPanel.Refresh();
}
+ private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
+ if (dlgSave.ShowDialog() == DialogResult.OK) {
+ //MessageBox.Show(dlgSave.FileName);
+
+ SaveBlock sav;
+ sav.monospaced = monospaced;
+ sav.frames = frames;
+ BinaryFormatter formatter = new BinaryFormatter();
+ using (System.IO.Stream ms = File.OpenWrite(dlgSave.FileName)) {
+ formatter.Serialize(ms, sav);
+ ms.Close();
+ }
+
+ //string filename = @"c:\temp\list.bin";
+ //var list = new List();
+ //list.Add(new X { N = 1, S = "No. 1" });
+ //list.Add(new X { N = 2, S = "No. 2" });
+ //list.Add(new X { N = 3, S = "No. 3" });
+ //BinaryFormatter formatter = new BinaryFormatter();
+ //using (System.IO.Stream ms = File.OpenWrite(filename)) {
+ // formatter.Serialize(ms, list);
+ //}
+
+ //using (FileStream fs = File.Open(filename, FileMode.Open)) {
+ // object obj = formatter.Deserialize(fs);
+ // var newlist = (List)obj;
+ // foreach (X x in newlist) {
+ // Console.Out.WriteLine($"N={x.N}, S={x.S}");
+ // }
+ //}
+
+
+
+ }
+ }
+
private void hScroll_ValueChanged(object sender, EventArgs e) {
label5.Text = hScroll.Value.ToString();
dotPanel.Refresh();
diff --git a/McBitFont/Form1.resx b/McBitFont/Form1.resx
index 29b8f36..f959525 100644
--- a/McBitFont/Form1.resx
+++ b/McBitFont/Form1.resx
@@ -123,4 +123,10 @@
127, 17
+
+ 242, 17
+
+
+ 336, 17
+
\ No newline at end of file
diff --git a/McBitFont/New.Designer.cs b/McBitFont/New.Designer.cs
index 5d390fe..3a66ea5 100644
--- a/McBitFont/New.Designer.cs
+++ b/McBitFont/New.Designer.cs
@@ -201,7 +201,9 @@
//
// New
//
+ this.AcceptButton = this.btnOK;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
+ this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(284, 161);
this.Controls.Add(this.cbSingle);
this.Controls.Add(this.btnCancel);
diff --git a/McBitFont/Program.cs b/McBitFont/Program.cs
index 21cbe08..6e0426e 100644
--- a/McBitFont/Program.cs
+++ b/McBitFont/Program.cs
@@ -13,7 +13,7 @@ namespace McBitFont {
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
+ Application.Run(new MainForm());
}
}
}