diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs index 54f7c22..8bfb15a 100644 --- a/McBitFont/Form1.Designer.cs +++ b/McBitFont/Form1.Designer.cs @@ -53,6 +53,7 @@ this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -403,6 +404,7 @@ this.newToolStripMenuItem, this.openToolStripMenuItem, this.saveToolStripMenuItem, + this.saveAsToolStripMenuItem, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); @@ -414,7 +416,7 @@ this.newToolStripMenuItem.Name = "newToolStripMenuItem"; 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(152, 22); + this.newToolStripMenuItem.Size = new System.Drawing.Size(184, 22); this.newToolStripMenuItem.Text = "New"; this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); // @@ -424,7 +426,7 @@ this.openToolStripMenuItem.Name = "openToolStripMenuItem"; 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(152, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(184, 22); this.openToolStripMenuItem.Text = "Open"; this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // @@ -434,9 +436,20 @@ this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; 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(152, 22); - this.saveToolStripMenuItem.Text = "Save as"; - this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.saveToolStripMenuItem.Text = "Save"; + this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click_1); + // + // saveAsToolStripMenuItem + // + this.saveAsToolStripMenuItem.Image = global::McBitFont.Properties.Resources.Famfamfam_Silk_Disk_16; + this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; + this.saveAsToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+S"; + this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.S))); + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.saveAsToolStripMenuItem.Text = "Save as"; + this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // // exitToolStripMenuItem // @@ -444,7 +457,7 @@ this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+X"; this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.X))); - this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(184, 22); this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -538,7 +551,7 @@ this.mirrorYToolStripMenuItem, this.exportToolStripMenuItem}); this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - this.toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); + this.toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); this.toolsToolStripMenuItem.Text = "Tools"; // // shiftUpToolStripMenuItem @@ -716,7 +729,7 @@ private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; @@ -739,6 +752,7 @@ private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; private System.Windows.Forms.Button btnBaseline; + private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; } } diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 842ba1b..8a83ea0 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -53,6 +53,7 @@ namespace McBitFont { bool prjModified = false; public const string version = "1.6"; public string prjName = "Untitled"; + public string prjFileName = ""; public int codepage = 1251; private FrameMiniature fbuf; private bool fbuffer = false; @@ -118,12 +119,12 @@ namespace McBitFont { private void dotPanel_MouseWheel(object sender, MouseEventArgs e) { int t = e.Delta / 120; if (e.Delta == 0) return; - if (ModifierKeys.HasFlag(Keys.Shift)) { + if (ModifierKeys.HasFlag(Keys.Control)) { t += cbZoom.SelectedIndex; if (t > cbZoom.Items.Count - 1) return; if (t < 0) return; cbZoom.SelectedIndex = t; - } else if (ModifierKeys.HasFlag(Keys.Control)) { + } else if (ModifierKeys.HasFlag(Keys.Shift)) { if (hScroll.Enabled) { t = t * -1 * (cellSize + gap) + hScroll.Value; if (t < hScroll.Minimum) t = hScroll.Minimum; @@ -595,6 +596,7 @@ namespace McBitFont { baseline = 0; prjName = "Untitled"; + prjFileName = ""; this.Text = "McBitFont " + version + " - " + prjName; modified = false; checkForAdd(); @@ -637,11 +639,7 @@ namespace McBitFont { } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { - if (modified) { - if (MessageBox.Show("Current frame is modified.\nDo you want to apply the changes first?", "The frame was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) { - saveFrame(); - } - } + checkModifiedFrame(); if (dlgSave.ShowDialog() == DialogResult.OK) { SaveBlock sav; sav.monospaced = monospaced; @@ -655,6 +653,7 @@ namespace McBitFont { } prjModified = false; prjName = Path.GetFileNameWithoutExtension(dlgSave.FileName); + prjFileName = dlgSave.FileName; this.Text = "McBitFont " + version + " - " + prjName; } } @@ -693,16 +692,34 @@ namespace McBitFont { modified = false; prjModified = false; + prjFileName = filename; prjName = Path.GetFileNameWithoutExtension(filename); this.Text = "McBitFont " + version + " - " + prjName; checkForAdd(); fbuffer = false; } + private void saveProject(string filename) { + SaveBlock sav; + sav.monospaced = monospaced; + sav.frames = frames; + sav.codepage = codepage; + sav.baseline = baseline; + BinaryFormatter formatter = new BinaryFormatter(); + using (Stream ms = File.OpenWrite(filename)) { + formatter.Serialize(ms, sav); + ms.Close(); + } + prjModified = false; + prjName = Path.GetFileNameWithoutExtension(filename); + prjFileName = filename; + this.Text = "McBitFont " + version + " - " + prjName; + } + private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (prjModified) { if (MessageBox.Show("The project is modified.\nDo you want to save it first?", "Project was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) { - saveToolStripMenuItem.PerformClick(); + saveAsToolStripMenuItem.PerformClick(); return; } } @@ -774,6 +791,25 @@ namespace McBitFont { set_base = !set_base; } + // Check modified / Save frame + private void checkModifiedFrame() { + if (modified) { + if (MessageBox.Show("Current frame is modified.\nDo you want to apply the changes first?", "The frame was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) { + saveFrame(); + } + } + } + + private void saveToolStripMenuItem_Click_1(object sender, EventArgs e) { + if (prjFileName == "") { + saveAsToolStripMenuItem.PerformClick(); + } else { + checkModifiedFrame(); + saveProject(prjFileName); + } + + } + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (prjModified) { if (MessageBox.Show("The project is modified.\nAre you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {