private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Balls doc file (*.bls)|*.bls"; openFileDialog.Title = "Open balls doc file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formater = new BinaryFormatter(); ballsDoc = (BallsDoc)formater.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); ballsDoc = new BallsDoc(); generateBall = 0; random = new Random(); timer = new Timer(); timer.Interval = 100; timer.Tick += new EventHandler(timer_Tick); timer.Start(); DoubleBuffered = true; }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { ballsDoc = new BallsDoc(); Invalidate(true); }
private void newToolStripButton_Click(object sender, EventArgs e) { ballsDoc = new BallsDoc(); Invalidate(true); }