Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Catch_Me
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Button_MouseEnter(object sender, EventArgs e)
- {
- Random rand = new Random();
- var maxWidth = this.ClientSize.Width - Button.ClientSize.Width;
- var maxHeight = this.ClientSize.Height - Button.ClientSize.Height;
- this.Button.Location = new Point(rand.Next(maxWidth), rand.Next(maxHeight));
- }
- private void Button_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Congratulations You win!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement