Advertisement
Guest User

Catch_Me

a guest
Oct 27th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. namespace Catch_Me
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.  
  10.         private void Button_MouseEnter(object sender, EventArgs e)
  11.         {
  12.             Random rand = new Random();
  13.             var maxWidth = this.ClientSize.Width - Button.ClientSize.Width;
  14.             var maxHeight = this.ClientSize.Height - Button.ClientSize.Height;
  15.             this.Button.Location = new Point(rand.Next(maxWidth), rand.Next(maxHeight));
  16.         }
  17.  
  18.         private void Button_Click(object sender, EventArgs e)
  19.         {
  20.             MessageBox.Show("Congratulations You win!");
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement