Esempio n. 1
0
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            GridCellUi test = Cells.Where(cell => cell.Location.X < e.X && cell.Location.Y < e.Y).Last();

            engine.SwitchCellState(test.X, test.Y);
            SwitchColorState(test);
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        private void Engine_CellStateChanged(object sender, CellStateChangedEventArgs e)
        {
            GridCellUi test = Cells.Where(cell => cell.X == e.CellAfterChange.X && cell.Y == e.CellAfterChange.Y).First();

            SwitchColorState(test);
        }