private void panel_Click(object sender, EventArgs e) { LightsOutPanel panel = (LightsOutPanel)sender; //MessageBox.Show(x.ToString()+ " , " + y.ToString()); changeAction(panel.coordX, panel.coordY); Form form = (Form)panel.Parent; checkWin(form); }
private void GameStart_Click(object sender, EventArgs e) { lightsOutPanels = new LightsOutPanel[width_x, length_y]; Form gameForm = new Form(); gameForm.Size = new Size((width_x * 49) + 40, (length_y * 49) + 50); for (int x = 0; x < width_x; x++) { for (int y = 0; y < length_y; y++) { LightsOutPanel panel = new LightsOutPanel(x, y); panel.Click += new EventHandler(panel_Click); panel.changeColor(); panel.Size = new Size(48, 48); panel.Location = new Point((x * 49) + 5, (y * 49) + 5); gameForm.Controls.Add(panel); lightsOutPanels[x, y] = panel; } } setup_Game(); gameForm.Show(); }