Beispiel #1
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     if (pauseToolStripMenuItem.Text != "Resume")
     {
         BallDoc.IsHit(e.X, e.Y);
         Invalidate(true);
     }
 }
Beispiel #2
0
 public Form1()
 {
     InitializeComponent();
     BallDoc  = new BallDoc(this.Width);
     FileName = string.Empty;
     if (pauseToolStripMenuItem.Text != "Resume")
     {
         timer1.Start();
     }
     _rand = new Random();
     this.DoubleBuffered = true;
 }
Beispiel #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (_counter % 8 == 0) // add a ball
            {
                BallDoc.AddBall(new Point(-Ball.Radius * 2,
                                          _rand.Next(Ball.Radius * 2 + toolStrip1.Height,
                                                     this.Height - statusStrip1.Height - Ball.Radius * 2 - 10)));
            }

            ++_counter;
            BallDoc.Move();
            Invalidate(true);
        }
Beispiel #4
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            var res = MessageBox.Show("Are you sure you want to start a new game?", "Start a new game",
                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                BallDoc  = new BallDoc(this.Width);
                FileName = string.Empty;
                pauseToolStripMenuItem.Text = "Pause";
                timer1.Start();
                Invalidate(true);
                return;
            }

            if (pauseToolStripMenuItem.Text != "Resume")
            {
                timer1.Start();
            }
        }
Beispiel #5
0
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.Clear(Color.White);
     BallDoc.Draw(e.Graphics);
 }