Пример #1
0
        /**
         * User undo a click.
         */
        private void Undo_Click(object sender, EventArgs e)
        {
            if (step.Count == 0 || move <= 0)  // should not undo under these circumstances
            {
                return;
            }
            Point_coord tmp = (Point_coord)step.Pop();
            int         x   = tmp.x;
            int         y   = tmp.y;

            FlipPlus(x, y);
            move--;
            moveCount.Text = move.ToString();
        }
Пример #2
0
        /**
         * A light button is clicked. Flip the color of this button and buttons around.
         */
        private void Button_Click(object sender, EventArgs e)
        {
            Button curr = (Button)sender;
            string name = curr.Name;

            name.ToCharArray();
            int i = name[1] - '0';
            int j = name[2] - '0';

            FlipPlus(i, j);
            move++;  // increase the count of user click

            Point_coord coord = new Point_coord(i, j);

            step.Push(coord);  // record the move
            moveCount.Text = move.ToString();
            CheckWin();
        }