private void OfferSaveAndClose() { DialogResult result = MessageBox.Show("Do you wish to save the current project?", "Save Current Project?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == System.Windows.Forms.DialogResult.Yes) { SaveFileDialog sfd = new SaveFileDialog(); sfd.OverwritePrompt = true; DialogResult sfdResult = sfd.ShowDialog(); if (sfdResult == System.Windows.Forms.DialogResult.OK) { Stream stream; if ((stream = sfd.OpenFile()) != null) { BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, currentProject); stream.Close(); } } } currentProject = null; }
private void OpenDefaultProject() { Stream stream; string defaultProjectFilePath = "C:\\Users\\dovieya\\Desktop\\TestContentLoader\\testProject.ff"; if (File.Exists(defaultProjectFilePath)) { if ((stream = File.OpenRead(defaultProjectFilePath)) != null) { BinaryFormatter bFormatter = new BinaryFormatter(); currentProject = (FyriProject)bFormatter.Deserialize(stream); stream.Close(); } } }
private void OpenProject() { OpenFileDialog ofd = new OpenFileDialog(); DialogResult result = ofd.ShowDialog(); if (result == DialogResult.OK) { Stream stream; if ((stream = ofd.OpenFile()) != null) { BinaryFormatter bFormatter = new BinaryFormatter(); currentProject = (FyriProject)bFormatter.Deserialize(stream); stream.Close(); } } }