private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Rectangles file (*.rct)|*.rct"; openFileDialog.Title = "Rectangles Rectangles"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formater = new BinaryFormatter(); Rectangles = (Rectangles)formater.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); DoubleBuffered = true; timer = new Timer(); timer.Interval = 500; timer.Tick += new EventHandler(timer_Tick); Rectangles = new Rectangles(); timer.Start(); color = Color.Red; }
private void newToolStripButton_Click(object sender, EventArgs e) { Rectangles = new Rectangles(); }