예제 #1
0
        private void buttonGuessColor_Click(object sender, EventArgs e)
        {
            m_ChooseColorForm.ShowDialog();
            if (m_ChooseColorForm.DialogResult == DialogResult.OK)
            {
                int colorNum            = GameColors.GetColorNumber(m_ChooseColorForm.UserColorChoice);
                int totalOfCurrentColor = m_UserGuessInput.Count(element => element.Equals(colorNum));
                if (totalOfCurrentColor > 0)
                {
                    MessageBox.Show(k_DuplicateColorMessage, "Duplicate Choice");
                }
                else
                {
                    (sender as Button).BackColor = m_ChooseColorForm.UserColorChoice;
                    if (m_UserGuessInput[getSquarePosition((Button)sender).Column] == 0)
                    {
                        m_CurrentUserInputLength++;
                    }

                    m_UserGuessInput[getSquarePosition((Button)sender).Column] = colorNum;
                }
            }

            if (m_CurrentUserInputLength == r_MaxLengthOfInput)
            {
                enableApprovalButton(getSquarePosition((Button)sender).Row);
            }
        }
예제 #2
0
        public void BuildColorsTable()
        {
            int currentNumColor = 0;

            for (int row = 0; row < k_NumOfRows; row++)
            {
                for (int col = 0; col < k_NumOfColorsInRow; col++)
                {
                    Button buttonToAdd = new Button();
                    buttonToAdd.Size      = new Size(45, 45);
                    buttonToAdd.Click    += button_Click;
                    buttonToAdd.BackColor = GameColors.GetColorName(currentNumColor);
                    currentNumColor++;
                    m_TableOfColors.Controls.Add(buttonToAdd, col, row);
                }
            }

            m_TableOfColors.AutoSize = true;
            m_TableOfColors.Left     = 5;
            m_TableOfColors.Top      = 5;
            Controls.Add(m_TableOfColors);
        }
예제 #3
0
 private void exposeHiddenFirstLine(int[] i_HiddenSequence)
 {
     for (int col = 0; col < r_MaxLengthOfInput; col++)
     {
         m_GameBoard.GetControlFromPosition(col, k_HiddenSquaresRow).BackColor = GameColors.GetColorName(i_HiddenSequence[col] - 1);
     }
 }