Open file; Resize the whole project.
This commit is contained in:
41
McBitFont/Form1.Designer.cs
generated
41
McBitFont/Form1.Designer.cs
generated
@@ -57,7 +57,6 @@
|
|||||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.addSymbolToolStripMenuItem = 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.fontOptionsToolStripMenuItem = 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();
|
||||||
@@ -312,11 +311,11 @@
|
|||||||
//
|
//
|
||||||
this.outBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.outBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.outBox.Font = new System.Drawing.Font("Consolas", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
this.outBox.Font = new System.Drawing.Font("Consolas", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
this.outBox.Location = new System.Drawing.Point(685, 105);
|
this.outBox.Location = new System.Drawing.Point(724, 105);
|
||||||
this.outBox.Multiline = true;
|
this.outBox.Multiline = true;
|
||||||
this.outBox.Name = "outBox";
|
this.outBox.Name = "outBox";
|
||||||
this.outBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
this.outBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||||
this.outBox.Size = new System.Drawing.Size(96, 40);
|
this.outBox.Size = new System.Drawing.Size(57, 40);
|
||||||
this.outBox.TabIndex = 11;
|
this.outBox.TabIndex = 11;
|
||||||
this.outBox.Text = "Output text here";
|
this.outBox.Text = "Output text here";
|
||||||
//
|
//
|
||||||
@@ -353,7 +352,7 @@
|
|||||||
this.button2.Name = "button2";
|
this.button2.Name = "button2";
|
||||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||||
this.button2.TabIndex = 13;
|
this.button2.TabIndex = 13;
|
||||||
this.button2.Text = "button2";
|
this.button2.Text = "Apply";
|
||||||
this.button2.UseVisualStyleBackColor = true;
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||||
//
|
//
|
||||||
@@ -382,11 +381,11 @@
|
|||||||
//
|
//
|
||||||
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.label5.AutoSize = true;
|
this.label5.AutoSize = true;
|
||||||
this.label5.Location = new System.Drawing.Point(683, 89);
|
this.label5.Location = new System.Drawing.Point(670, 135);
|
||||||
this.label5.Name = "label5";
|
this.label5.Name = "label5";
|
||||||
this.label5.Size = new System.Drawing.Size(35, 13);
|
this.label5.Size = new System.Drawing.Size(24, 13);
|
||||||
this.label5.TabIndex = 16;
|
this.label5.TabIndex = 16;
|
||||||
this.label5.Text = "label5";
|
this.label5.Text = "X,Y";
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
@@ -415,27 +414,28 @@
|
|||||||
// newToolStripMenuItem
|
// newToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
|
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
|
||||||
this.newToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.newToolStripMenuItem.Size = new System.Drawing.Size(103, 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);
|
||||||
//
|
//
|
||||||
// openToolStripMenuItem
|
// openToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||||
this.openToolStripMenuItem.Text = "Open";
|
this.openToolStripMenuItem.Text = "Open";
|
||||||
|
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// saveToolStripMenuItem
|
// saveToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.saveToolStripMenuItem.Text = "Save";
|
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(180, 22);
|
this.exitToolStripMenuItem.Size = new System.Drawing.Size(103, 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);
|
||||||
//
|
//
|
||||||
@@ -443,30 +443,25 @@
|
|||||||
//
|
//
|
||||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.addSymbolToolStripMenuItem,
|
this.addSymbolToolStripMenuItem,
|
||||||
this.removeSymbolToolStripMenuItem,
|
this.removeSymbolToolStripMenuItem});
|
||||||
this.fontOptionsToolStripMenuItem});
|
|
||||||
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
|
// addSymbolToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
this.addSymbolToolStripMenuItem.Enabled = false;
|
||||||
this.addSymbolToolStripMenuItem.Name = "addSymbolToolStripMenuItem";
|
this.addSymbolToolStripMenuItem.Name = "addSymbolToolStripMenuItem";
|
||||||
this.addSymbolToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
|
this.addSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.addSymbolToolStripMenuItem.Text = "Add symbol";
|
this.addSymbolToolStripMenuItem.Text = "Add symbol";
|
||||||
//
|
//
|
||||||
// removeSymbolToolStripMenuItem
|
// removeSymbolToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
this.removeSymbolToolStripMenuItem.Enabled = false;
|
||||||
this.removeSymbolToolStripMenuItem.Name = "removeSymbolToolStripMenuItem";
|
this.removeSymbolToolStripMenuItem.Name = "removeSymbolToolStripMenuItem";
|
||||||
this.removeSymbolToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
|
this.removeSymbolToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.removeSymbolToolStripMenuItem.Text = "Remove symbol";
|
this.removeSymbolToolStripMenuItem.Text = "Remove symbol";
|
||||||
//
|
//
|
||||||
// fontOptionsToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.fontOptionsToolStripMenuItem.Name = "fontOptionsToolStripMenuItem";
|
|
||||||
this.fontOptionsToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
|
|
||||||
this.fontOptionsToolStripMenuItem.Text = "Font Options";
|
|
||||||
//
|
|
||||||
// toolsToolStripMenuItem
|
// toolsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@@ -532,6 +527,7 @@
|
|||||||
//
|
//
|
||||||
// aboutToolStripMenuItem
|
// aboutToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
this.aboutToolStripMenuItem.Enabled = false;
|
||||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||||
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
|
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
|
||||||
this.aboutToolStripMenuItem.Text = "About";
|
this.aboutToolStripMenuItem.Text = "About";
|
||||||
@@ -544,7 +540,6 @@
|
|||||||
// dlgOpen
|
// dlgOpen
|
||||||
//
|
//
|
||||||
this.dlgOpen.DefaultExt = "mbf";
|
this.dlgOpen.DefaultExt = "mbf";
|
||||||
this.dlgOpen.FileName = "openFileDialog1";
|
|
||||||
this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*";
|
this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*";
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
@@ -573,6 +568,7 @@
|
|||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "McBitFont";
|
this.Text = "McBitFont";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||||
this.Load += new System.EventHandler(this.Form1_Load);
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudX)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.nudX)).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudY)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.nudY)).EndInit();
|
||||||
@@ -619,7 +615,6 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem addSymbolToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem addSymbolToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem removeSymbolToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem removeSymbolToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem fontOptionsToolStripMenuItem;
|
|
||||||
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem shiftUpToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem shiftUpToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem shiftDownToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem shiftDownToolStripMenuItem;
|
||||||
|
@@ -46,6 +46,7 @@ namespace McBitFont {
|
|||||||
private int w, h;
|
private int w, h;
|
||||||
bool monospaced = false;
|
bool monospaced = false;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
bool prjModified = true;
|
||||||
|
|
||||||
public MainForm() {
|
public MainForm() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -112,13 +113,59 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void nudX_ValueChanged(object sender, EventArgs e) {
|
private void nudX_ValueChanged(object sender, EventArgs e) {
|
||||||
|
if (monospaced) {
|
||||||
|
Bitmap bmp;
|
||||||
|
for (int i = 0; i < frames.Count; i++) {
|
||||||
|
frames[i] = frameResize(frames[i], (int)nudX.Value, dotHeight);
|
||||||
|
bmp = getMiniPictue(frames[i]);
|
||||||
|
string s = frames[i].code.ToString();
|
||||||
|
ilMiniatures.Images.RemoveByKey(s);
|
||||||
|
ilMiniatures.Images.Add(s, (Image)bmp);
|
||||||
|
miniList.Items[s].ImageKey = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prjModified = true;
|
||||||
dotResize((int)nudX.Value, dotHeight);
|
dotResize((int)nudX.Value, dotHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nudY_ValueChanged(object sender, EventArgs e) {
|
private void nudY_ValueChanged(object sender, EventArgs e) {
|
||||||
|
Bitmap bmp;
|
||||||
|
for (int i = 0; i < frames.Count; i++) {
|
||||||
|
frames[i] = frameResize(frames[i], dotWidth, (int)nudY.Value);
|
||||||
|
bmp = getMiniPictue(frames[i]);
|
||||||
|
string s = frames[i].code.ToString();
|
||||||
|
ilMiniatures.Images.RemoveByKey(s);
|
||||||
|
ilMiniatures.Images.Add(s, (Image)bmp);
|
||||||
|
miniList.Items[s].ImageKey = s;
|
||||||
|
}
|
||||||
|
prjModified = true;
|
||||||
dotResize(dotWidth, (int)nudY.Value);
|
dotResize(dotWidth, (int)nudY.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FrameMiniature frameResize(FrameMiniature ff, int neww, int newh) {
|
||||||
|
int oldw = ff.width;
|
||||||
|
int oldh = ff.height;
|
||||||
|
int imax, jmax;
|
||||||
|
bool[,] t;
|
||||||
|
|
||||||
|
if (neww < oldw) imax = neww;
|
||||||
|
else imax = oldw;
|
||||||
|
if (newh < oldh) jmax = newh;
|
||||||
|
else jmax = oldh;
|
||||||
|
|
||||||
|
ff.width = neww;
|
||||||
|
ff.height = newh;
|
||||||
|
t = new bool[neww, newh];
|
||||||
|
for (int i=0; i<imax; i++) {
|
||||||
|
for (int j=0;j<jmax; j++) {
|
||||||
|
t[i, j] = ff.data[i, j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ff.data = t;
|
||||||
|
|
||||||
|
return ff;
|
||||||
|
}
|
||||||
|
|
||||||
private void dotResize(int ww, int hh) {
|
private void dotResize(int ww, int hh) {
|
||||||
int imax, jmax;
|
int imax, jmax;
|
||||||
bool[,] t;
|
bool[,] t;
|
||||||
@@ -203,7 +250,7 @@ namespace McBitFont {
|
|||||||
|
|
||||||
private void dotPanel_MouseMove(object sender, MouseEventArgs e) {
|
private void dotPanel_MouseMove(object sender, MouseEventArgs e) {
|
||||||
if (e.X >= w || e.X <= pixelOffset || e.Y >= h || e.Y <= pixelOffset) return;
|
if (e.X >= w || e.X <= pixelOffset || e.Y >= h || e.Y <= pixelOffset) return;
|
||||||
label3.Text = e.X.ToString() + ',' + e.Y.ToString();
|
//label3.Text = e.X.ToString() + ',' + e.Y.ToString();
|
||||||
int i = (e.X - pixelOffset + hScroll.Value) / (cellSize + gap);
|
int i = (e.X - pixelOffset + hScroll.Value) / (cellSize + gap);
|
||||||
int j = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap);
|
int j = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap);
|
||||||
label5.Text = i.ToString() + ',' + j.ToString();
|
label5.Text = i.ToString() + ',' + j.ToString();
|
||||||
@@ -339,13 +386,14 @@ namespace McBitFont {
|
|||||||
ilMiniatures.Images.Add(s, (Image)sizedBMP);
|
ilMiniatures.Images.Add(s, (Image)sizedBMP);
|
||||||
sizedBMP.Dispose();
|
sizedBMP.Dispose();
|
||||||
modified = false;
|
modified = false;
|
||||||
|
prjModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap getMiniPictue(FrameMiniature m) {
|
private Bitmap getMiniPictue(FrameMiniature m) {
|
||||||
int picSize = (m.width > m.height) ? m.width : m.height;
|
int picSize = (m.width > m.height) ? m.width : m.height;
|
||||||
var bmp = new Bitmap(picSize, picSize);
|
var bmp = new Bitmap(picSize, picSize);
|
||||||
int imin = m.width < picSize ? (picSize - m.width) / 2 - 1 : 0;
|
int imin = m.width < picSize ? (picSize - m.width) / 2 : 0;
|
||||||
int jmin = m.height < picSize ? (picSize - m.height) / 2 - 1 : 0;
|
int jmin = m.height < picSize ? (picSize - m.height) / 2 : 0;
|
||||||
Color c;
|
Color c;
|
||||||
for (int i = 0; i < m.width; i++) {
|
for (int i = 0; i < m.width; i++) {
|
||||||
for (int j = 0; j < m.height; j++) {
|
for (int j = 0; j < m.height; j++) {
|
||||||
@@ -388,6 +436,12 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void newToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void newToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
|
if (prjModified) {
|
||||||
|
if (MessageBox.Show("The project is modified.\nDo you want to save the changes?", "Project was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
||||||
|
saveToolStripMenuItem.PerformClick();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
New form = new New();
|
New form = new New();
|
||||||
if (form.ShowDialog() == DialogResult.OK) {
|
if (form.ShowDialog() == DialogResult.OK) {
|
||||||
frames.Clear();
|
frames.Clear();
|
||||||
@@ -419,7 +473,6 @@ namespace McBitFont {
|
|||||||
monospaced = form.rbMono.Checked;
|
monospaced = form.rbMono.Checked;
|
||||||
foreach (FrameMiniature ff in frames) {
|
foreach (FrameMiniature ff in frames) {
|
||||||
var s = ff.code.ToString();
|
var s = ff.code.ToString();
|
||||||
//var c = System.Text.Encoding.ASCII.
|
|
||||||
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
|
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
|
||||||
miniList.Items.Add(s, s+' '+append+(char)ff.code, s);
|
miniList.Items.Add(s, s+' '+append+(char)ff.code, s);
|
||||||
}
|
}
|
||||||
@@ -450,39 +503,68 @@ namespace McBitFont {
|
|||||||
|
|
||||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
if (dlgSave.ShowDialog() == DialogResult.OK) {
|
if (dlgSave.ShowDialog() == DialogResult.OK) {
|
||||||
//MessageBox.Show(dlgSave.FileName);
|
|
||||||
|
|
||||||
SaveBlock sav;
|
SaveBlock sav;
|
||||||
sav.monospaced = monospaced;
|
sav.monospaced = monospaced;
|
||||||
sav.frames = frames;
|
sav.frames = frames;
|
||||||
BinaryFormatter formatter = new BinaryFormatter();
|
BinaryFormatter formatter = new BinaryFormatter();
|
||||||
using (System.IO.Stream ms = File.OpenWrite(dlgSave.FileName)) {
|
using (Stream ms = File.OpenWrite(dlgSave.FileName)) {
|
||||||
formatter.Serialize(ms, sav);
|
formatter.Serialize(ms, sav);
|
||||||
ms.Close();
|
ms.Close();
|
||||||
}
|
}
|
||||||
|
prjModified = false;
|
||||||
//string filename = @"c:\temp\list.bin";
|
|
||||||
//var list = new List<X>();
|
|
||||||
//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<X>)obj;
|
|
||||||
// foreach (X x in newlist) {
|
|
||||||
// Console.Out.WriteLine($"N={x.N}, S={x.S}");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
|
if (prjModified) {
|
||||||
|
if (MessageBox.Show("The project is modified.\nDo you want to save the changes?", "Project was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
||||||
|
saveToolStripMenuItem.PerformClick();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (dlgOpen.ShowDialog() == DialogResult.OK) {
|
||||||
|
//MessageBox.Show(dlgOpen.FileName);
|
||||||
|
SaveBlock sav;
|
||||||
|
BinaryFormatter formatter = new BinaryFormatter();
|
||||||
|
|
||||||
|
using (FileStream fs = File.Open(dlgOpen.FileName, FileMode.Open)) {
|
||||||
|
sav = (SaveBlock)formatter.Deserialize(fs);
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
monospaced = sav.monospaced;
|
||||||
|
frames = sav.frames;
|
||||||
|
miniList.Items.Clear();
|
||||||
|
ilMiniatures.Images.Clear();
|
||||||
|
foreach (FrameMiniature ff in frames) {
|
||||||
|
var s = ff.code.ToString();
|
||||||
|
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
|
||||||
|
miniList.Items.Add(s, s + ' ' + (char)ff.code, s);
|
||||||
|
}
|
||||||
|
nudX.ValueChanged -= nudX_ValueChanged;
|
||||||
|
nudY.ValueChanged -= nudY_ValueChanged;
|
||||||
|
nudX.Value = frames.First().width;
|
||||||
|
nudY.Value = frames.First().height;
|
||||||
|
dotResize((int)nudX.Value, (int)nudY.Value);
|
||||||
|
nudX.ValueChanged += nudX_ValueChanged;
|
||||||
|
nudY.ValueChanged += nudY_ValueChanged;
|
||||||
|
f = frames.First();
|
||||||
|
dotPanel.Refresh();
|
||||||
|
miniList.Refresh();
|
||||||
|
modified = false;
|
||||||
|
prjModified = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
|
||||||
|
if (prjModified) {
|
||||||
|
if (MessageBox.Show("The project is modified.\nDo you want to save the changes?", "Project was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
||||||
|
saveToolStripMenuItem.PerformClick();
|
||||||
|
e.Cancel = true;
|
||||||
|
} else {
|
||||||
|
e.Cancel = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void hScroll_ValueChanged(object sender, EventArgs e) {
|
private void hScroll_ValueChanged(object sender, EventArgs e) {
|
||||||
label5.Text = hScroll.Value.ToString();
|
label5.Text = hScroll.Value.ToString();
|
||||||
|
Reference in New Issue
Block a user