Exemplo n.º 1
0
        private void CommonHandler_TextChanged(object sender, EventArgs e)
        {
            Control currentCell = sudokuPanel.Controls.Find((sender as TextBox).Name, true)[0];

            string[] splitArray = (sender as TextBox).Name.Split('_');

            if (beingWiped != currentCell)
            {
                if (currentCell.Text != "")
                {
                    if (!game.IsDigitsOnly(currentCell.Text))
                    {
                        ShowIncorrectInput(currentCell);
                    }
                    else if (int.Parse(currentCell.Text) > game.numberOfSquares || int.Parse(currentCell.Text) == 0)
                    {
                        ShowIncorrectInput(currentCell);
                    }
                    else
                    {
                        game.SetByColumn(int.Parse(currentCell.Text), int.Parse(splitArray[1]), int.Parse(splitArray[2]));
                        CheckHighlighting(game.GetByColumn(int.Parse(splitArray[1]), int.Parse(splitArray[2])));
                        IsPuzzleFinished();
                    }
                }
                else
                {
                    CheckHighlighting(game.GetByColumn(int.Parse(splitArray[1]), int.Parse(splitArray[2])));
                }
            }
        }