Exemplo n.º 1
0
        private void openGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FileName == null)
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "Ball flying docs (*.bfd)|*.bfd";
                dialog.Title  = "Open your flying doc";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    FileName = dialog.FileName;
                }
                try
                {
                    using (FileStream stream = new FileStream(FileName, FileMode.Open))
                    {
                        var formatter = new BinaryFormatter();
                        ball = (BallDoc)formatter.Deserialize(stream);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while saving  the file");
                }
            }
        }
Exemplo n.º 2
0
 public Form1()
 {
     InitializeComponent();
     timer1.Start();
     ball = new BallDoc();
     this.DoubleBuffered = true;
     r        = new Random();
     FileName = null;
     pause    = false;
 }
Exemplo n.º 3
0
 private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ball = new BallDoc();
 }