private void AddButtonsIntoRows(List <string> listOfLetters, int tableColumn, ref int buttonIndex, ref BingoButton[] buttons) { for (int i = 0; i < 5; i++) { buttons[buttonIndex] = new BingoButton(); buttons[buttonIndex].Name = $"btn{listOfLetters[i]}"; buttons[buttonIndex].Text = listOfLetters[i]; buttons[buttonIndex].FlatStyle = FlatStyle.System; buttons[buttonIndex].Click += DaubAsync; buttons[buttonIndex].Row = i; buttons[buttonIndex].Column = tableColumn; tblBingoBoard.Controls.Add(buttons[buttonIndex], tableColumn, i + 1); buttonIndex++; } }
public Bingo() { IsGamePlaying = false; InitializeComponent(); _core = new Core(); _synth = new SpeechSynthesizer(); List <string> letters = new List <string> { "B", "I", "N", "G", "O" }; Button[] buttons = new Button[30]; BingoButton[] bingoButtonsbuttons = new BingoButton[30]; int buttonIndex = 0; Daubed = new bool[5, 5]; //For testing bingo //_core.ListOfPlayingLetters.AddRange(_core.ListOfAllPossibleLetters); CheckCornerBingo = true; CheckColumn0Bingo = true; CheckColumn1Bingo = true; CheckColumn2Bingo = true; CheckColumn3Bingo = true; CheckColumn4Bingo = true; CheckRow0Bingo = true; CheckRow1Bingo = true; CheckRow2Bingo = true; CheckRow3Bingo = true; CheckRow4Bingo = true; CheckLeftCrossBingo = true; CheckRightCrossBingo = true; AddButtonsIntoHeaderRow(letters, ref buttonIndex, ref buttons); //AddButtonsIntoRows(_core.PlayableB, 0, ref buttonIndex, ref buttons); //AddButtonsIntoRows(_core.PlayableI, 1, ref buttonIndex, ref buttons); //AddButtonsIntoRows(_core.PlayableN, 2, ref buttonIndex, ref buttons); //AddButtonsIntoRows(_core.PlayableG, 3, ref buttonIndex, ref buttons); //AddButtonsIntoRows(_core.PlayableO, 4, ref buttonIndex, ref buttons); AddButtonsIntoRows(_core.PlayableB, 0, ref buttonIndex, ref bingoButtonsbuttons); AddButtonsIntoRows(_core.PlayableI, 1, ref buttonIndex, ref bingoButtonsbuttons); AddButtonsIntoRows(_core.PlayableN, 2, ref buttonIndex, ref bingoButtonsbuttons); AddButtonsIntoRows(_core.PlayableG, 3, ref buttonIndex, ref bingoButtonsbuttons); AddButtonsIntoRows(_core.PlayableO, 4, ref buttonIndex, ref bingoButtonsbuttons); }