Exemple #1
0
        private void colorButton_Click(object sender, EventArgs e)
        {
            ColorButton clickedButton = sender as ColorButton;

            m_ChosenColor = Array.IndexOf(ColorsOfButtons, clickedButton.BackColor);
            Close();
        }
Exemple #2
0
 private void setGuessButtons(int i_RowOffset)
 {
     m_GuessButtons = new List <ColorButton>();
     for (int i = 0; i < k_NumberOfButtonsInARow; i++)
     {
         ColorButton newButton = new ColorButton(Button.DefaultBackColor);
         newButton.Enabled  = !k_IsButtonEnabled;
         newButton.Location = new Point(
             k_MarginOfButtonFromLeft + (newButton.Width / 2) + (k_NumberOfButtonsInARow * newButton.Width) + (k_ButtonMargin * i) + (i * newButton.Width),
             k_MarginOfButtonFromTop + (i_RowOffset * (newButton.Height + k_MarginBetweenButtonRows)));
         m_GuessButtons.Add(newButton);
     }
 }
Exemple #3
0
        private void setListOfCorrectGuess()
        {
            m_CorrectGuessLine = new List <ColorButton>();

            for (int i = 0; i < k_NumberOfButtonsInLine; i++)
            {
                ColorButton newButton = new ColorButton(Color.Black);
                newButton.Enabled  = !k_IsButtonEnabled;
                newButton.Location = new Point(
                    k_MarginOfButtonFromLeft + (newButton.Width / 2) + (k_NumberOfButtonsInLine * newButton.Width) + (i * k_ButtonMargin) + (i * newButton.Width),
                    k_MarginOfButtonFromTop);
                m_CorrectGuessLine.Add(newButton);
                Controls.Add(newButton);
            }
        }
Exemple #4
0
        private void colorButton_Click(object sender, EventArgs eventArgs)
        {
            ColorButton clickedButton = sender as ColorButton;
            ColorPicker colorPicker   = new ColorPicker();

            colorPicker.ShowDialog();
            int chosenColorIndex = colorPicker.ChosenColor;

            if (chosenColorIndex != -1)
            {
                clickedButton.BackColor = ColorPicker.ColorsOfButtons[chosenColorIndex];
            }

            checkIfFullGuess(m_CurrentGuessNumber);
        }
Exemple #5
0
        private void setRow(int i_RowOffset)
        {
            int numberOfButtonsInARow = ColorsOfButtons.Length / k_NumberOfRows;

            for (int numberOfButtonInTheRow = 0; numberOfButtonInTheRow < numberOfButtonsInARow; numberOfButtonInTheRow++)
            {
                ColorButton newButton = new ColorButton(ColorsOfButtons[numberOfButtonInTheRow + (i_RowOffset * numberOfButtonsInARow)]);
                newButton.Location = new Point(
                    k_MarginOfButtonFromLeft + (newButton.Width / 2) + (numberOfButtonInTheRow * newButton.Width) + (numberOfButtonInTheRow * k_ButtonMargin),
                    k_MarginOfButtonFromTop + (i_RowOffset * (newButton.Height + k_MarginBetweenButtonRows)));

                Controls.Add(newButton);

                newButton.Click += new EventHandler(colorButton_Click);
            }
        }