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 WindowsFormsApplication17 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } void VytvorKarticky() { int N = 6; int sx = ClientSize.Width / N; int sy = ClientSize.Height / N; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { Button b = new Button(); b.Width = sx; b.Height = sy; b.Left = i * sx; b.Top = j * sy; b.Text = "PEXESO"; b.Tag = (i * N + j) / 2 + 1; b.Click += KLIK; b.Parent = this; } } Button Prvni = null; Button Druhy = null; private void KLIK(object sender, EventArgs e) { switch (stav) { case Stav.HRA: Prvni = (Button)sender; Prvni.Text = Prvni.Tag.ToString(); NastavStav(Stav.JEDNA); break; case Stav.JEDNA: break; case Stav.DVE: break; } } private void button1_Click(object sender, EventArgs e) { VytvorKarticky(); } enum Stav {UVOD, HRA, JEDNA, DVE, KONEC}; Stav stav = Stav.UVOD; void NastavStav( Stav novy) { switch (novy) { case Stav.UVOD: bStart.Visible = true; break; case Stav.HRA: bStart.Visible = false; if (stav == Stav.UVOD) VytvorKarticky(); break; case Stav.JEDNA: break; case Stav.DVE: break; case Stav.KONEC: break; default: break; } stav = novy; } private void bStart_Click(object sender, EventArgs e) { NastavStav(Stav.HRA); } } }