static public void LoadProject(string filename) { if (!File.Exists(filename)) { MessageBox.Show(MainWindow, "Project file could not be loaded because it does not exist!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Close the current project before loading the new one if (Project != null) { CloseProject(); } //Load it XmlSerializer xs = new XmlSerializer(typeof(Project)); Stream s = new FileStream(filename, FileMode.Open); Project = (Project)xs.Deserialize(s); s.Close(); Project.Filename = filename; //Error check string errors = Project.ErrorCheck(); if (errors == "") { FinishProjectEdit(FinishProjectEditAction.LoadAndSaveProject); } else { MessageBox.Show(MainWindow, "Project could not be loaded because of the following errors:\n" + errors + "\nFix the errors to continue with loading.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); EditProject(ProjectEditMode.ErrorOnLoad); } }