Ejemplo n.º 1
0
        // Called by the Grid during an Update for each visible cell
        private void gridBoard_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
        {
            // Disallow editing
            e.Style.Enabled = false;

            if (e.ColIndex > 0 && e.RowIndex > 0)
            {
                if (game.IsGameRunning)
                {
                    e.Style.Interior = GetGradient(game.GetBoardSquare(e.ColIndex, e.RowIndex));
                }
                else
                {
                    // Being able to see the board while paused is a significant advantage
                    e.Style.BackColor = Color.White;
                }
            }

            // Add text to the CoveredCells for Game Over and Paused messages
            if (e.RowIndex == 6)
            {
                if (game.IsGameOver && e.ColIndex == 2)
                {
                    e.Style.Text = "Game Over";
                    e.Style.Font = ArialFontInfo;
                }
                else if (!game.IsGameRunning && game.IsGameStarted && !game.IsGameOver && e.ColIndex == 3)
                {
                    e.Style.Text = "Paused";
                    e.Style.Font = ArialFontInfo;
                }
            }
        }