示例#1
0
文件: View.cs 项目: huarthu/CSGOL
        /// <summary>
        /// Changement de la taille de la grille
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void trBarSize_Changed(object sender, EventArgs e)
        {
            int newSize = (trBarSize.Value + 1) * 10;

            cellGrid.InitCells(newSize);
            DrawCells(cellGrid);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        public void NextGrid()
        {
            var temp = new CellGrid(this.panelSize);

            temp.InitCells(this.width);
            var  next       = temp.cells;
            byte cellsAlive = 0;

            for (int i = 0; i < this.cells.Count; i++)
            {
                cellsAlive = 0;
                foreach (Cell c in cells[i].neighbors)
                {
                    if (c.isAlive)
                    {
                        cellsAlive++;
                    }
                }
                if (cellsAlive == 3 || (cellsAlive == 2 && cells[i].isAlive == true))
                {
                    next[i].SwitchCell(true);
                }
                else
                {
                    next[i].SwitchCell(false);
                }
            }
            this.cells = next;
        }
示例#3
0
文件: View.cs 项目: huarthu/CSGOL
        /// <summary>
        /// Chargement de la vue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void View_Load(object sender, EventArgs e)
        {
            cellGrid = new CellGrid(pnlCells.Width);
            cellGrid.InitCells((trBarSize.Value + 1) * 10);

            timer          = new System.Timers.Timer(20);
            timer.Elapsed += timerTick;
            DrawCells(cellGrid);
        }