Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows.Forms;
- using System.Drawing;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- class RandomNext
- {
- public class Randomgenerator : Random
- {
- Random random = new Random ();
- }
- }
- class ProgramWindow1
- {
- static void Main()
- {
- // Het scherm zelf //
- ProgramForm scherm;
- scherm = new ProgramForm();
- Application.Run(scherm);
- }
- }
- class ProgramForm : Form
- {
- public void Startknop()
- {
- // De startknop //
- Button startButton;
- startButton = new Button();
- startButton.Text = "Start";
- startButton.BackColor = Color.LightGoldenrodYellow;
- startButton.Location = new System.Drawing.Point(100, 100);
- startButton.Height = 100;
- startButton.Width = 100;
- startButton.Font = new Font("Georgia", 16);
- startButton.Anchor = AnchorStyles.None;
- int x = this.Width / 2 - startButton.Width / 2;
- int y = this.Height / 2 - startButton.Height / 2;
- startButton.Location = new System.Drawing.Point(x, y);
- this.Controls.Add(startButton);
- }
- public void reactieknop()
- {
- // De reactieknop //
- Button reactieButton;
- reactieButton = new Button();
- reactieButton.BackColor = Color.MintCream;
- reactieButton.Location = new System.Drawing.Point(rX, rY);
- reactieButton.Height = rX;
- reactieButton.Width = rY;
- }
- public ProgramForm()
- {
- // Scherm openen en maximaliseren //
- this.Text = "Prakticumopdracht 1";
- this.BackColor = Color.PowderBlue;
- this.WindowState = FormWindowState.Maximized;
- // Eigenschappen startknop //
- Button startButton;
- startButton = new Button();
- startButton.Text = "Start";
- startButton.BackColor = Color.LightGoldenrodYellow;
- startButton.Height = 100;
- startButton.Width = 100;
- startButton.Font = new Font("Georgia", 16);
- startButton.Anchor = AnchorStyles.None;
- int width = this.Width / 2 - startButton.Width / 2;
- int height = this.Height / 2 - startButton.Height / 2;
- startButton.Location = new System.Drawing.Point(width, height);
- // Eventhandler startknop //
- startButton.Click += new EventHandler(startButton_Click);
- startButton.Visible = true;
- // Eigenschappen reactieknop //
- Button reactieButton;
- reactieButton = new Button();
- reactieButton.BackColor = Color.MintCream;
- reactieButton.Location = new System.Drawing.Point(rX, rY);
- reactieButton.Height = rX;
- reactieButton.Width = rY;
- // Eventhandler reactieknop //
- reactieButton.Click += new EventHandler(reactieButton_Click);
- reactieButton.Visible = false;
- // Toevoegen aan Controls //
- this.Controls.Add(startButton);
- this.Controls.Add(reactieButton);
- }
- // Eventhandler startknop //
- void startButton_Click(object sender, EventArgs e)
- {
- Button ClickedButton = (Button)sender;
- ClickedButton.Visible = false;
- reactieButton.Visible = true;
- Random randomY = new Random();
- int rY = randomY.Next(10, 270);
- Random randomX = new Random();
- int rX = randomX.Next(10, 270);
- reactieButton.Location = new System.Drawing.Point(rX, rY);
- reactieButton.Height = rX;
- reactieButton.Width = rY;
- }
- // Eventhandler reactieknop //
- void reactieButton_Click(object sender, EventArgs e)
- {
- Button ClickedButton = (Button)sender;
- ClickedButton.Visible = false;
- startButton.Visible = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement