Advertisement
Guest User

Form1

a guest
Dec 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. public partial class Form1 : Form
  2.     {
  3.         public Form1()
  4.         {
  5.             InitializeComponent();
  6.             StreamReader sr = new StreamReader("kulonbsegek.txt");
  7.             while (!sr.EndOfStream)
  8.             {
  9.                 int x = int.Parse(sr.ReadLine());
  10.                 int y = int.Parse(sr.ReadLine());
  11.                 int szelesseg = int.Parse(sr.ReadLine());
  12.                 int magassag = int.Parse(sr.ReadLine());
  13.                 Kocka k = new Kocka();
  14.                 k.Top = y;
  15.                 k.Left = x;
  16.                 k.Width = szelesseg;
  17.                 k.Height = magassag;
  18.                 this.Controls.Add(k);
  19.                 k.Click += K_Click;
  20.             }
  21.         }
  22.  
  23.         private void K_Click(object sender, EventArgs e)
  24.         {
  25.             int darab = 0;
  26.             foreach (Kocka k in this.Controls)
  27.             {
  28.                 if (k.BackColor == Color.Red)
  29.                 {
  30.                     darab++;
  31.                 }
  32.             }
  33.  
  34.             if (darab == 15)
  35.             {
  36.                 MessageBox.Show("Nyertél");
  37.             }
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement