Ability to open a project by double-clicking on a file in Explorer
This commit is contained in:
@@ -89,6 +89,11 @@ namespace McBitFont {
|
||||
this.Text = "McBitFont " + version + " - " + prjName;
|
||||
|
||||
fbuf = new FrameMiniature(0, dotWidth, dotHeight);
|
||||
|
||||
// Chek for arguments
|
||||
if (Environment.GetCommandLineArgs().Length > 1) {
|
||||
loadProject(Environment.GetCommandLineArgs()[1]);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
@@ -654,18 +659,11 @@ namespace McBitFont {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (dlgOpen.ShowDialog() == DialogResult.OK) {
|
||||
private void loadProject(string filename) {
|
||||
SaveBlock sav;
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
|
||||
using (FileStream fs = File.Open(dlgOpen.FileName, FileMode.Open)) {
|
||||
using (FileStream fs = File.Open(filename, FileMode.Open)) {
|
||||
sav = (SaveBlock)formatter.Deserialize(fs);
|
||||
fs.Close();
|
||||
}
|
||||
@@ -695,11 +693,22 @@ namespace McBitFont {
|
||||
modified = false;
|
||||
prjModified = false;
|
||||
|
||||
prjName = Path.GetFileNameWithoutExtension(dlgOpen.FileName);
|
||||
prjName = Path.GetFileNameWithoutExtension(filename);
|
||||
this.Text = "McBitFont " + version + " - " + prjName;
|
||||
checkForAdd();
|
||||
fbuffer = false;
|
||||
}
|
||||
|
||||
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();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (dlgOpen.ShowDialog() == DialogResult.OK) {
|
||||
loadProject(dlgOpen.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSymbolToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
|
Reference in New Issue
Block a user