private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog SaveFileDialog1 = new SaveFileDialog(); try { SaveFileDialog1.Title = "Save BRD Document"; SaveFileDialog1.Filter = "BRD Documents (*.brd)|*.brd"; if (SaveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } } catch { return; } currentFilePath = SaveFileDialog1.FileName; if (String.IsNullOrEmpty(currentFilePath)) { return; } FileSerializer.Serialize(currentFilePath, birds); MessageBox.Show("File " + currentFilePath + " saved.", "File Saved."); dirtyForm = false; }
public void Open() { OpenFileDialog OpenFileDialog1 = new OpenFileDialog(); OpenFileDialog1.Title = "Open BRD Document"; OpenFileDialog1.Filter = "BRD Documents (*.brd)|*.brd"; if (OpenFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } currentFilePath = OpenFileDialog1.FileName; if (String.IsNullOrEmpty(currentFilePath)) { return; } if (System.IO.File.Exists(currentFilePath) == false) { return; } birds = FileSerializer.Deserialize(currentFilePath); // Load bird at position zero if (birds != null) { currentBird = birds.ElementAt <BirdWatcher.BirdData>(0); LoadCurrentBird(); dirtyForm = false; } }