private void openGameToolStripMenuItem_Click(object sender, EventArgs e) { if (FileName == null) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Ball flying docs | (*.bfd)"; openFileDialog.Title = "Open your flying doc"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; } try { using (FileStream stream = new FileStream(FileName, FileMode.Open)) { var formatter = new BinaryFormatter(); ballDoc = (BallDoc)formatter.Deserialize(stream); //FileName = null; } } catch (Exception ex) { MessageBox.Show("Error while opening your file"); } } }
public Form1() { FileName = null; TimerCall = 0; ballDoc = new BallDoc(this.Width); timer1 = new Timer(); ballDoc.Width = this.Width; timer1.Start(); isPaused = false; InitializeComponent(); this.DoubleBuffered = true; }
private void newGameToolStripMenuItem_Click(object sender, EventArgs e) { ballDoc = new BallDoc(this.Width); }