private void Form1_MouseClick(object sender, MouseEventArgs e) { if (pauseToolStripMenuItem.Text != "Resume") { BallDoc.IsHit(e.X, e.Y); Invalidate(true); } }
public Form1() { InitializeComponent(); BallDoc = new BallDoc(this.Width); FileName = string.Empty; if (pauseToolStripMenuItem.Text != "Resume") { timer1.Start(); } _rand = new Random(); this.DoubleBuffered = true; }
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); }
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(); } }
private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.Clear(Color.White); BallDoc.Draw(e.Graphics); }