private void openProjectButton(object sender, EventArgs e) { // Show them the loading box. loadProject lp = new loadProject(); lp.Show(); // Get us a new FolderBrowserDialog CommonOpenFileDialog fb = new CommonOpenFileDialog(); fb.IsFolderPicker = true; fb.Title = "Please select the directory that your project resides in."; fb.EnsurePathExists = true; CommonFileDialogResult rs = fb.ShowDialog(); if (rs == CommonFileDialogResult.Cancel) { lp.Close(); return; } // Get the path. string dir = fb.FileName; // Avoid the annoying An error occured dialog. if (string.IsNullOrEmpty(dir) || !Directory.Exists(dir)) { lp.Close(); return; } // Load the project. bool stat = lp.openProjDir(dir); // Check the status. if (stat == false) { MessageBox.Show("An error occured while loading the project, some files could not be found or the project is corrupt. Please try repairing your project.", "Opening Mod Builder project", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Tyvm! lp.Close(); }
private void regenerateSQLToolStripMenuItem_Click(object sender, EventArgs e) { // If we have no working directory set, we have no saved project here or the project has become corrupt. Either way, cancel. if (!Directory.Exists(workingDirectory)) { MessageBox.Show("Either your project is not saved or you have a corrupted project. Please try saving your project.", "Regenerating SQL", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Confirmation... DialogResult result = MessageBox.Show("Are you sure you want to regenerate the database file? You will lose all your data!", "Regenrating SQL", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); // They're sure. Lets start. if (result == DialogResult.Yes) { // Close any open connection we may have. if (hasConn) conn.Close(); // Try to delete the file; catch an IOException when it occurs. try { File.Delete(workingDirectory + "/data.sqlite"); } catch (IOException) { MessageBox.Show("The database file is in use by another process. Please try again in a few seconds.", "Regenerating SQL", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Then regenerate the SQL file. generateSQL(workingDirectory); // Information. MessageBox.Show("A new database has been generated. Your project will now be reloaded.", "Regenerating SQL", MessageBoxButtons.OK, MessageBoxIcon.Information); // And reload the project to take advantage of the changes. loadProject lp = new loadProject(); lp.Show(); lp.openProjDir(workingDirectory); lp.Close(); Close(); } }
private void openProjectToolStripMenuItem_Click(object sender, EventArgs e) { // Show them the loading box. loadProject lp = new loadProject(); lp.Show(); // Get us a new FolderBrowserDialog CommonOpenFileDialog fb = new CommonOpenFileDialog(); fb.IsFolderPicker = true; fb.Title = "Please select the directory that your project resides in."; fb.EnsurePathExists = true; fb.ShowDialog(); // Get the path. string dir = fb.FileName; // Avoid the annoying An error occured dialog. if (string.IsNullOrEmpty(dir) || !Directory.Exists(dir)) { lp.Close(); return; } // Load the project. bool stat = lp.openProjDir(dir); // Check the status. if (stat == false) MessageBox.Show("An error occured while loading the project, some files could not be found or the project is corrupt.", "Open project", MessageBoxButtons.OK, MessageBoxIcon.Error); // Tyvm! lp.Close(); }