private void newDoc() { circlesDoc = new CirclesDoc(); previousPoint = Point.Empty; currentPoint = Point.Empty; FileName = "Untitled"; }
private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Circles doc file (*.cir)|*.cir"; openFileDialog.Title = "Open circles doc file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formater = new BinaryFormatter(); circlesDoc = (CirclesDoc)formater.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }