public void LoadProject(string filename) { this.filename = filename; var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (var sr = System.IO.File.OpenRead(filename)) { current_project = bin.Deserialize(sr) as GlorgProject; } folder = System.IO.Path.GetDirectoryName(filename); }
public void NewProject(string filename) { current_project = new GlorgProject(); this.filename = filename; var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (var sr = System.IO.File.OpenWrite(filename)) { bin.Serialize(sr, current_project); } if (!Properties.Settings.Default.RecentFileList.Contains(filename)) { Properties.Settings.Default.RecentFileList.Add(filename); } folder = System.IO.Path.GetDirectoryName(filename); }
public void LoadProject() { var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (var sr = System.IO.File.OpenRead(filename)) { try { var project = bin.Deserialize(sr) as GlorgProject; current_project = project; if (string.IsNullOrEmpty(current_project.ActiveMap) && current_project.Maps.Count > 0) { current_project.ActiveMap = current_project.Maps[0]; } } catch (System.Runtime.Serialization.SerializationException) { MessageBox.Show("Unable to load project.", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ArgumentNullException) { MessageBox.Show("Unable to open file.", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { if (string.IsNullOrEmpty(current_project.ActiveMap)) { LoadMap(current_project.ActiveMap); } } catch (Exception) { MessageBox.Show("Unable to open map '" + current_project.ActiveMap + "'", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void NewProject(string filename) { current_project = new GlorgProject(); this.filename = filename; var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (var sr = System.IO.File.OpenWrite(filename)) { bin.Serialize(sr, current_project); } if(!Properties.Settings.Default.RecentFileList.Contains(filename)) Properties.Settings.Default.RecentFileList.Add(filename); folder = System.IO.Path.GetDirectoryName(filename); }
public void LoadProject() { var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (var sr = System.IO.File.OpenRead(filename)) { try { var project = bin.Deserialize(sr) as GlorgProject; current_project = project; if(string.IsNullOrEmpty(current_project.ActiveMap) && current_project.Maps.Count > 0) current_project.ActiveMap = current_project.Maps[0]; } catch (System.Runtime.Serialization.SerializationException) { MessageBox.Show("Unable to load project.", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ArgumentNullException) { MessageBox.Show("Unable to open file.", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { if(string.IsNullOrEmpty(current_project.ActiveMap)) LoadMap(current_project.ActiveMap); } catch (Exception) { MessageBox.Show("Unable to open map '" + current_project.ActiveMap + "'", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }