private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Rectangles doc file (*.rct)|*.rct"; openFileDialog.Title = "Open rectangles doc file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); doc = (RectanglesDoc)formatter.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
private void newDoc() { doc = new RectanglesDoc(); previousPoint = Point.Empty; currentPoint = Point.Empty; FileName = "Untitled"; }
public Form1() { InitializeComponent(); start = Point.Empty; end = Point.Empty; this.DoubleBuffered = true; rectanglesDoc = new RectanglesDoc(); rectanglesDrawing = new RectanglesDoc(); }