Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp4
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Kino kn = new Kino();
- kn.KataskeuiKoumpiou();
- Controls.AddRange(kn.pinakas);
- Controls.Add(kn.Koumpi());
- }
- class Kino : Form1
- {
- public Button[] pinakas { get; set; } = new Button[80];
- private Random tixaios = new Random();
- public void KataskeuiKoumpiou()
- {
- int x = 0;
- int y = 0;
- for (int i = 0; i < 80; i++, x++)
- {
- if (i % 10 == 0 && i != 0)
- {
- y = y + 50;
- x = 0;
- }
- Button btn = new Button();
- btn.Width = btn.Height = 50;
- btn.Location = new Point(x * 50 + 50, y + 50);
- btn.Text = (i + 1).ToString();
- btn.Font = new Font(new FontFamily("Arial"), 16);
- pinakas[i] = btn;
- }
- }
- public Button Koumpi()
- {
- Button btn = new Button();
- btn.AutoSize = true;
- btn.Location = new Point(600, 100);
- btn.Text = "klirosi";
- btn.Font = new Font(new FontFamily("Arial"), 16);
- btn.Click += OnKlirosi;
- return btn;
- }
- private void OnKlirosi(object sender, EventArgs e)
- {
- Timer timer = new Timer();
- timer.Interval = 1000;
- timer.Start();
- timer.Tick += animate;
- }
- private void animate(object sender, EventArgs e)
- {
- pinakas[tixaios.Next(0, 80)].Enabled = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement