private void slotbutton_Click(object sender, EventArgs e) { int slot = int.Parse((sender as Button).Name.Substring(4, 1)); using (PlayerSelectorForm form = new PlayerSelectorForm()) { if (form.ShowDialog(this) == DialogResult.OK && form.SelectedPlayer != null) { var player = form.SelectedPlayer; slots[slot - 1] = player; Button slotRemoveButton = Controls["slot" + slot + "RemoveButton"] as Button; Label slotLabel = Controls["slot" + slot + "Label"] as Label; slotLabel.Text = player.Name; slotRemoveButton.Visible = true; } } }
public void PlayerMan(Player player) { PlayerSelectorForm selectorForm = new PlayerSelectorForm(_players.Values.ToArray()); player.OpenForm(selectorForm); }