private void OpenFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Lines doc file (*.lns)|*.lns"; openFileDialog.Title = "Open Lines doc file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream filestream = new FileStream(FileName, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); linesDoc = (LinesDocument)formatter.Deserialize(filestream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); linesDoc = new LinesDocument(Width, Height); DoubleBuffered = true; FileName = "Untitled"; normalToolStripMenuItem.Checked = true; }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { linesDoc = new LinesDocument(Width, Height); Invalidate(true); }