/// <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); }
/// <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; }
/// <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); }