Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. using System.Windows.Forms;
  2. using System.Drawing;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7.  
  8. class RandomNext
  9. {
  10. public class Randomgenerator : Random
  11. {
  12. Random random = new Random ();
  13. }
  14. }
  15. class ProgramWindow1
  16. {
  17. static void Main()
  18. {
  19. // Het scherm zelf //
  20. ProgramForm scherm;
  21. scherm = new ProgramForm();
  22. Application.Run(scherm);
  23. }
  24. }
  25. class ProgramForm : Form
  26. {
  27. public void Startknop()
  28. {
  29. // De startknop //
  30. Button startButton;
  31. startButton = new Button();
  32. startButton.Text = "Start";
  33. startButton.BackColor = Color.LightGoldenrodYellow;
  34. startButton.Location = new System.Drawing.Point(100, 100);
  35. startButton.Height = 100;
  36. startButton.Width = 100;
  37. startButton.Font = new Font("Georgia", 16);
  38. startButton.Anchor = AnchorStyles.None;
  39. int x = this.Width / 2 - startButton.Width / 2;
  40. int y = this.Height / 2 - startButton.Height / 2;
  41. startButton.Location = new System.Drawing.Point(x, y);
  42. this.Controls.Add(startButton);
  43. }
  44. public void reactieknop()
  45. {
  46. // De reactieknop //
  47. Button reactieButton;
  48. reactieButton = new Button();
  49. reactieButton.BackColor = Color.MintCream;
  50. reactieButton.Location = new System.Drawing.Point(rX, rY);
  51. reactieButton.Height = rX;
  52. reactieButton.Width = rY;
  53.  
  54. }
  55. public ProgramForm()
  56. {
  57. // Scherm openen en maximaliseren //
  58. this.Text = "Prakticumopdracht 1";
  59. this.BackColor = Color.PowderBlue;
  60. this.WindowState = FormWindowState.Maximized;
  61.  
  62. // Eigenschappen startknop //
  63. Button startButton;
  64. startButton = new Button();
  65. startButton.Text = "Start";
  66. startButton.BackColor = Color.LightGoldenrodYellow;
  67. startButton.Height = 100;
  68. startButton.Width = 100;
  69. startButton.Font = new Font("Georgia", 16);
  70. startButton.Anchor = AnchorStyles.None;
  71. int width = this.Width / 2 - startButton.Width / 2;
  72. int height = this.Height / 2 - startButton.Height / 2;
  73. startButton.Location = new System.Drawing.Point(width, height);
  74.  
  75. // Eventhandler startknop //
  76. startButton.Click += new EventHandler(startButton_Click);
  77. startButton.Visible = true;
  78.  
  79. // Eigenschappen reactieknop //
  80. Button reactieButton;
  81. reactieButton = new Button();
  82. reactieButton.BackColor = Color.MintCream;
  83. reactieButton.Location = new System.Drawing.Point(rX, rY);
  84. reactieButton.Height = rX;
  85. reactieButton.Width = rY;
  86.  
  87. // Eventhandler reactieknop //
  88. reactieButton.Click += new EventHandler(reactieButton_Click);
  89. reactieButton.Visible = false;
  90.  
  91. // Toevoegen aan Controls //
  92. this.Controls.Add(startButton);
  93. this.Controls.Add(reactieButton);
  94. }
  95. // Eventhandler startknop //
  96. void startButton_Click(object sender, EventArgs e)
  97. {
  98. Button ClickedButton = (Button)sender;
  99. ClickedButton.Visible = false;
  100. reactieButton.Visible = true;
  101. Random randomY = new Random();
  102. int rY = randomY.Next(10, 270);
  103. Random randomX = new Random();
  104. int rX = randomX.Next(10, 270);
  105. reactieButton.Location = new System.Drawing.Point(rX, rY);
  106. reactieButton.Height = rX;
  107. reactieButton.Width = rY;
  108. }
  109.  
  110. // Eventhandler reactieknop //
  111. void reactieButton_Click(object sender, EventArgs e)
  112. {
  113. Button ClickedButton = (Button)sender;
  114. ClickedButton.Visible = false;
  115. startButton.Visible = true;
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement