Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. public void Zufall()
  2. {
  3. int maxLeft = Convert.ToInt32(Grid1.ActualWidth - button1.Width);
  4. int maxTop = Convert.ToInt32(Grid1.ActualHeight - button1.Height);
  5.  
  6. Random rand1 = new Random(Guid.NewGuid().GetHashCode());
  7. Random rand2 = new Random(Guid.NewGuid().GetHashCode());
  8. Random rand3 = new Random(Guid.NewGuid().GetHashCode());
  9. Random rand4 = new Random(Guid.NewGuid().GetHashCode());
  10. Random rand5 = new Random(Guid.NewGuid().GetHashCode());
  11. Random rand6 = new Random(Guid.NewGuid().GetHashCode());
  12.  
  13. Brush brush1 = new SolidColorBrush(Color.FromRgb((byte)rand1.Next(1, 255), (byte)rand1.Next(1, 255), (byte)rand1.Next(1, 233)));
  14. Brush brush2 = new SolidColorBrush(Color.FromRgb((byte)rand2.Next(1, 255), (byte)rand2.Next(1, 255), (byte)rand2.Next(1, 233)));
  15. Brush brush3 = new SolidColorBrush(Color.FromRgb((byte)rand2.Next(1, 255), (byte)rand2.Next(1, 255), (byte)rand2.Next(1, 233)));
  16. Brush brush4 = new SolidColorBrush(Color.FromRgb((byte)rand2.Next(1, 255), (byte)rand2.Next(1, 255), (byte)rand2.Next(1, 233)));
  17. Brush brush5 = new SolidColorBrush(Color.FromRgb((byte)rand2.Next(1, 255), (byte)rand2.Next(1, 255), (byte)rand2.Next(1, 233)));
  18. Brush brush6 = new SolidColorBrush(Color.FromRgb((byte)rand2.Next(1, 255), (byte)rand2.Next(1, 255), (byte)rand2.Next(1, 233)));
  19.  
  20.  
  21. button1.Margin = new Thickness(rand1.Next(maxLeft), rand1.Next(maxTop), 0, 0);
  22. button1.Height = rand1.Next(maxTop);
  23. button1.Width = rand1.Next(maxLeft);
  24. button1.Background = brush1;
  25.  
  26. Background.Fill = brush2;
  27.  
  28. Rectangle1.Margin = new Thickness(rand3.Next(maxLeft), rand3.Next(maxTop), 0, 0);
  29. Rectangle1.Height = rand3.Next(maxTop);
  30. Rectangle1.Width = rand3.Next(maxLeft);
  31. Rectangle1.Fill = brush3;
  32.  
  33. Rectangle2.Margin = new Thickness(rand4.Next(maxLeft), rand4.Next(maxTop), 0, 0);
  34. Rectangle2.Height = rand4.Next(maxTop);
  35. Rectangle2.Width = rand4.Next(maxLeft);
  36. Rectangle2.Fill = brush4;
  37.  
  38. Rectangle3.Margin = new Thickness(rand5.Next(maxLeft), rand5.Next(maxTop), 0, 0);
  39. Rectangle3.Height = rand5.Next(maxTop);
  40. Rectangle3.Width = rand5.Next(maxLeft);
  41. Rectangle3.Fill = brush5;
  42.  
  43. Rectangle4.Margin = new Thickness(rand6.Next(maxLeft), rand6.Next(maxTop), 0, 0);
  44. Rectangle4.Height = rand6.Next(maxTop);
  45. Rectangle4.Width = rand6.Next(maxLeft);
  46. Rectangle4.Fill = brush6;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement