示例#1
0
        // when a user double clicks a square on the TicTacToeForm this method receives the
        // event message
        // the current move is set and the alreadyMoved flag is set to true so that the
        // which breaks the while loop in the Move method
        void SquareDoubleClicked(object sender, TicTacToeBoardClickedEventArgs args)
        {
            // unregister the double clicked event
            ticTacToeForm.SquareDoubleClicked -= SquareDoubleClicked;

            currentMove  = new TicTacToeMove(args.BoardPosition, this.PlayerPiece);
            alreadyMoved = true;
        }
		// when a user double clicks a square on the TicTacToeForm this method receives the 
		// event message
		// the current move is set and the alreadyMoved flag is set to true so that the 
		// which breaks the while loop in the Move method
		void SquareClicked(object sender, TicTacToeBoardClickedEventArgs args)
		{
			// unregister the double clicked event
			//HACK:            ticTacToeForm.SquareDoubleClicked -= SquareDoubleClicked;

			currentMove = new TicTacToeMove(args.BoardPosition, this.PlayerPiece);
			alreadyMoved = true;
		}
        void ticTacToePanel_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int position = TranslateMouseClickToPosition(e.X, e.Y);

            // we will only process the event and notify any clients of the SquareDoubleClicked
            // event if the the square is empty
            if (this.game.GameBoard.IsValidSquare(position))
            {
                // Determine the position of th square clicked on the panel and then inoke the event
                TicTacToeBoardClickedEventArgs t = new TicTacToeBoardClickedEventArgs(position);

                if (SquareDoubleClicked != null)
                {
                    SquareDoubleClicked(this, t);
                }
            }
        }