public Form1() { InitializeComponent(); polygonDoc = new PolygonDocument(); isClicked = false; this.DoubleBuffered = true; }
private void open() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Polygons doc file (*.poly)|*.poly"; openFileDialog.Title = "Open polygons doc"; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); polygonDoc = (PolygonDocument)formatter.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }