Esempio n. 1
0
        private void Grid_Paint(object sender, PaintEventArgs e)
        {
            if (GameIsOn)
            {
                this.BackColor = Consts.Colors.GameForm;
            }
            else
            {
                this.BackColor = Consts.Colors.SetupForm;
            }

            if (GameIsOn)
            {
                game.CalculateTomorrow();
            }


            foreach (var cell in game.Universe)
            {
                if (GameIsOn)
                {
                    var color = cell.IsAlive ? new SolidBrush(Consts.Colors.AliveCell) : new SolidBrush(Consts.Colors.DeadCell);
                    e.Graphics.FillRectangle(color, cell.X * Consts.CellSize, cell.Y * Consts.CellSize, Consts.CellSize - 1, Consts.CellSize - 1);
                }
                else
                {
                    var color = cell.IsAlive ? new SolidBrush(Consts.Colors.SetupAliveCell) : new SolidBrush(Consts.Colors.SetupDeadCell);
                    e.Graphics.FillRectangle(color, cell.X * Consts.CellSize, cell.Y * Consts.CellSize, Consts.CellSize - 1, Consts.CellSize - 1);
                }
            }
        }