Advertisement
Guest User

Untitled

a guest
Feb 16th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. static readonly int[][] locations = new int[][] { new int[] { 337, 104 }, new int[] { 443, 104 }, new int[] { 549, 104 }, new int[] { 655, 104 }, new int[] { 761, 104 }, new int[] { 337, 210 }, new int[] { 443, 210 }, new int[] { 549, 210 }, new int[] { 655, 210 }, new int[] { 761, 210 } };
  2.  
  3.         protected int[][] getRandomLocs(int[][] locs)
  4.         {
  5.             Random rnd = new Random();
  6.  
  7.             for (int i = 0; i < locs.Length; ++i)
  8.             {
  9.                 int next = rnd.Next(locs.Length);
  10.                 int[] temp = locs[next];
  11.                 locs[next] = locs[i];
  12.                 locs[i] = temp;
  13.             }
  14.  
  15.             return locs;
  16.         }
  17.  
  18.         private void Form1_Load(object sender, EventArgs e)
  19.         {
  20.             int i = 0;
  21.             var temp = getRandomLocs(locations);
  22.  
  23.             foreach (object item in this.Controls)
  24.             {
  25.                 if (item is PictureBox)
  26.                 {
  27.                     ((PictureBox)item).Location = new Point(temp[i][0], temp[i][1]);
  28.                     i++;
  29.                 }
  30.             }
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement