Esempio n. 1
0
        void MyButtonClick(object sender, EventArgs e)
        //Event handler used for any number button click
        {
            if (buttons.Contains((Button)sender))
            {
                char[] buttonName = ((Button)sender).Name.ToCharArray();

                int row    = buttonName[1] - 48;
                int column = buttonName[3] - 48;

                //This line is to make conditional statement more clear
                SudokuNumber buttonNumber = game.entries[Sudoku.CurrentEntry(row, column)];

                if (!buttonNumber.correct & lastButton == ((Button)sender))
                {
                    int?newValue = game.Increment(row, column);

                    ((Button)sender).Text = Convert.ToString(newValue);
                }
                lastButton = ((Button)sender);
            }
        }