public void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Ballons doc file (*.bal)|*.bal"; openFileDialog.Title = "Open ballons file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); ballonsList = (BallonsList)formatter.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); ballonsList = new BallonsList(); this.DoubleBuffered = true; timer1 = new Timer(); timer1.Interval = 200; timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { ballonsList = new BallonsList(); Invalidate(); }