//Method with initial settings when the window is loaded private void GameForm_Load(object sender, EventArgs e) { PictureBox[] box = { Harten2, Harten3, Harten4, Harten5, Harten6, Harten7, Harten8, Harten9, Harten10, HartenBoer, HartenVrouw, HartenHeer, HartenAas, Schoppen2, Schoppen3, Schoppen4, Schoppen5, Schoppen6, Schoppen7, Schoppen8, Schoppen9, Schoppen10, SchoppenBoer, SchoppenVrouw, SchoppenHeer, SchoppenAas, Klaveren2, Klaveren3, Klaveren4, Klaveren5, Klaveren6, Klaveren7, Klaveren8, Klaveren9, Klaveren10, KlaverenBoer, KlaverenVrouw, KlaverenHeer, KlaverenAas, Ruiten2, Ruiten3, Ruiten4, Ruiten5, Ruiten6, Ruiten7, Ruiten8, Ruiten9, Ruiten10, RuitenBoer, RuitenVrouw, RuitenHeer, RuitenAas, pictureBox14 }; foreach (PictureBox pBox in box) { pBox.Hide(); } priceLabel.BackColor = System.Drawing.Color.Transparent; turnPlayerLabel.BackColor = System.Drawing.Color.Transparent; resetButton.Hide(); buyCardButton.Hide(); standingButton.Hide(); scoreButton.Hide(); player1NameLabel.Hide(); BetPlayer1TextBox.Hide(); scorePlayer1TextBox.Hide(); player2LabelName.Hide(); BetPlayer2TextBox.Hide(); scorePlayer2TextBox.Hide(); player3LabelName.Hide(); BetPlayer3TextBox.Hide(); scorePlayer3TextBox.Hide(); player4LabelName.Hide(); BetPlayer4TextBox.Hide(); scorePlayer4TextBox.Hide(); player5LabelName.Hide(); BetPlayer5TextBox.Hide(); scorePlayer5TextBox.Hide(); scoreHouseTextBox.Enabled = false; scoreHouseTextBox.Hide(); scoreHouseTextBox.Text = "Score: " + dal.house.GetValueOfHand(); priceLabel.Text = "Prijzenpot: " + dal.price.GetPrice().ToString(); DetermineNumberOfPlayers(); }
//Method to determine the number of active players and show the correct textboxes and labels public void DetermineNumberOfPlayers() { int numberOfPlayers = dal.game.playerList.Count(); if (numberOfPlayers >= 1) { player1NameLabel.Text = dal.game.playerList[0].GetName(); BetPlayer1TextBox.Text = dal.game.playerList[0].GetBet().ToString(); scorePlayer1TextBox.Text = "Score: " + dal.game.playerList[0].GetValueOfHand().ToString(); player1NameLabel.Show(); BetPlayer1TextBox.Show(); scorePlayer1TextBox.Show(); BetPlayer1TextBox.Enabled = false; scorePlayer1TextBox.Enabled = false; } if (numberOfPlayers >= 2) { player2LabelName.Text = dal.game.playerList[1].GetName(); BetPlayer2TextBox.Text = dal.game.playerList[1].GetBet().ToString(); scorePlayer2TextBox.Text = "Score: " + dal.game.playerList[1].GetValueOfHand().ToString(); player2LabelName.Show(); BetPlayer2TextBox.Show(); scorePlayer2TextBox.Show(); BetPlayer2TextBox.Enabled = false; scorePlayer2TextBox.Enabled = false; } if (numberOfPlayers >= 3) { player3LabelName.Text = dal.game.playerList[2].GetName(); BetPlayer3TextBox.Text = dal.game.playerList[2].GetBet().ToString(); scorePlayer3TextBox.Text = "Score: " + dal.game.playerList[2].GetValueOfHand().ToString(); player3LabelName.Show(); BetPlayer3TextBox.Show(); scorePlayer3TextBox.Show(); BetPlayer3TextBox.Enabled = false; scorePlayer3TextBox.Enabled = false; } if (numberOfPlayers >= 4) { player4LabelName.Text = dal.game.playerList[3].GetName(); BetPlayer4TextBox.Text = dal.game.playerList[3].GetBet().ToString(); scorePlayer4TextBox.Text = "Score: " + dal.game.playerList[3].GetValueOfHand().ToString(); player4LabelName.Show(); BetPlayer4TextBox.Show(); scorePlayer4TextBox.Show(); BetPlayer4TextBox.Enabled = false; scorePlayer4TextBox.Enabled = false; } if (numberOfPlayers >= 5) { player5LabelName.Text = dal.game.playerList[4].GetName(); BetPlayer5TextBox.Text = dal.game.playerList[4].GetBet().ToString(); scorePlayer5TextBox.Text = "Score: " + dal.game.playerList[4].GetValueOfHand().ToString(); player5LabelName.Show(); BetPlayer5TextBox.Show(); scorePlayer5TextBox.Show(); BetPlayer5TextBox.Enabled = false; scorePlayer5TextBox.Enabled = false; } }