Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 } };
- protected int[][] getRandomLocs(int[][] locs)
- {
- Random rnd = new Random();
- for (int i = 0; i < locs.Length; ++i)
- {
- int next = rnd.Next(locs.Length);
- int[] temp = locs[next];
- locs[next] = locs[i];
- locs[i] = temp;
- }
- return locs;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- int i = 0;
- var temp = getRandomLocs(locations);
- foreach (object item in this.Controls)
- {
- if (item is PictureBox)
- {
- ((PictureBox)item).Location = new Point(temp[i][0], temp[i][1]);
- i++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement