Example #1
0
        private void SwitchColorState(GridCellUi cell)
        {
            var cellSize = CalculateCellSize(panel1);

            if (cell.State == CellState.Alive)
            {
                pen.Color = DeadColor;
            }
            else
            {
                pen.Color = AliveColor;
            }

            Rectangle rect    = new Rectangle(cell.Location.X, cell.Location.Y, cellSize, cellSize);
            Graphics  myGraph = panel1.CreateGraphics();

            myGraph.FillRectangle(new SolidBrush(pen.Color), rect);
            pen.Color = BorderColor;
            myGraph.DrawRectangle(pen, rect);
            cell.switchState();
        }