public ChoicePanel(GameInterface g) { gameInterface = g; BackColor = Color.CornflowerBlue; //Size = new Size(300, 140); textLabel = new Label(); textLabel.Size = new Size(280, 40); textLabel.Location = new Point(10, 10); textLabel.Font = new Font(new FontFamily("Comic Sans MS"), 14); for (int i = 0; i < buttons.Length; i++) { ChoiceButton b = new ChoiceButton(); b.BackColor = Color.GhostWhite; b.Visible = false; b.Font = new Font(new FontFamily("Comic Sans MS"), 12); b.Location = new Point(5 + (i % 3) * 80, 100 + 50*(i/3)); b.Click += (sender, args) => { buttonPressed(b); }; buttons[i] = b; Controls.Add(b); } Controls.Add(textLabel); }
private void buttonPressed(ChoiceButton b) { gameInterface.gameElementPressed(b.getElement()); }