private void arrowButton_Click(object sender, EventArgs e) { int correctInPlace = 0; int correctMissPlaced = 0; GuessButton arrowButton = sender as GuessButton; if (arrowButton != null) { arrowButton.Enabled = false; disableRow(arrowButton.Row); List <char> currentGuess = m_PlayersGuesses[arrowButton.Row]; this.m_CurrentGame.FeedbackForPlayerGuess( currentGuess, out correctInPlace, out correctMissPlaced); showScore(arrowButton.Row, correctInPlace, correctMissPlaced); if (correctInPlace == 4 || arrowButton.Row + 1 == r_NumberOfRounds) { disableAllRows(); displaySequence(); } else if (arrowButton.Row + 1 < r_NumberOfRounds) { enableRow(arrowButton.Row + 1); } } }
private GuessButton generateArrowButton(int i_RowNumber) { GuessButton arrowButton = new GuessButton(i_RowNumber); arrowButton.Size = new Size(40, 20); arrowButton.Location = new Point(195, 90 + (45 * i_RowNumber)); arrowButton.Text = "-->>"; arrowButton.TextAlign = ContentAlignment.MiddleCenter; arrowButton.Enabled = false; return(arrowButton); }
private void colorButton_Click(object sender, EventArgs e) { GuessButton colorButton = sender as GuessButton; if (colorButton != null) { m_Guess.Add(colorButton.Guess); m_ChosenColor = colorButton.BackColor; } this.Close(); }
private List <Button> generateScoreButtons(int i_RowNumber) { List <Button> scoreButtons = new List <Button>(); for (int i = 0; i < k_NumberOfButtonsInGuess; i++) { GuessButton scoreButton = new GuessButton(i_RowNumber, i); scoreButton.Enabled = false; scoreButton.Size = new Size(15, 15); scoreButton.Location = new Point(this.ClientSize.Width - scoreButton.Width - 10 - (20 * (i % 2)), 80 + (20 * (i / 2) + (45 * i_RowNumber))); scoreButtons.Add(scoreButton); } return(scoreButtons); }
private void guessButton_Click(object sender, EventArgs e) { GuessButton guessButton = sender as GuessButton; if (guessButton != null) { PickAColorForm colorsForm = new PickAColorForm( guessButton.Row, guessButton.Colum, m_PlayersGuesses[guessButton.Row]); colorsForm.ShowDialog(); m_PlayersGuesses[guessButton.Row] = colorsForm.Guess; guessButton.BackColor = colorsForm.ChosenColor; guessButton.SetGuess = true; if (allRowSet(guessButton.Row)) { m_ArrowButtons[guessButton.Row].Enabled = true; } } }
protected void initControls(int i_Row, int i_Colum) { Color[] buttonsColors = { Color.Orchid, Color.Red, Color.Lime, Color.Cyan, Color.MediumBlue, Color.Yellow, Color.Brown, Color.White }; for (int i = 0; i < 8; i++) { char currentGuess = (char)('A' + i); GuessButton currentButton = new GuessButton(i_Row, i_Colum, currentGuess); currentButton.BackColor = buttonsColors[i]; currentButton.Location = new Point(10 + ((i / 2) * 50), 10 + ((i % 2) * 50)); if (m_Guess.Contains(currentGuess)) { currentButton.Enabled = false; } m_ColoredButtons.Add(currentButton); } this.Controls.AddRange(m_ColoredButtons.ToArray()); }
private void initControls() { List <Control> controls = new List <Control>(); for (int i = 0; i < k_NumberOfButtonsInGuess; i++) { SequenceButton blackButton = new SequenceButton(); blackButton.Enabled = false; blackButton.Location = new Point(15 + (45 * i), 15); m_BlackButtons.Add(blackButton); controls.Add(blackButton); } for (int row = 0; row < r_NumberOfRounds; row++) { List <GuessButton> buttonsInRow = new List <GuessButton>(); for (int colum = 0; colum < k_NumberOfButtonsInGuess; colum++) { GuessButton grayButton = new GuessButton(row, colum); if (row != 0) { grayButton.Enabled = false; } grayButton.Location = new Point(15 + (45 * colum), 80 + (45 * row)); buttonsInRow.Add(grayButton); controls.Add(grayButton); } m_GuessBottonsRows.Add(buttonsInRow); m_ArrowButtons.Add(generateArrowButton(row)); m_ScoreButtons.Add(generateScoreButtons(row)); controls.Add(m_ArrowButtons[row]); controls.AddRange(m_ScoreButtons[row].ToArray()); } this.Controls.AddRange(controls.ToArray()); }