Example #1
0
        private void CreateCellViewModelRow(int rowNumber)
        {
            _logger.Log($"Create {rowNumber} row of cells");
            var row = new ObservableCollection <ICellViewModel>();

            for (var x = 0; x < Automaton.Size.Width; x++)
            {
                var cellViewModel = new CellViewModel(Settings, Automaton.GetCell(x, rowNumber));
                row.Add(cellViewModel);
            }

            _logger.Log($"{rowNumber} row of cells is ready for rendering");
            Cells.Add(row);
        }
Example #2
0
        private void UpdateCellViewModelRow(int rowNumber)
        {
            var row = Cells[rowNumber];

            // delete additional cells
            while (row.Count > Automaton.Size.Width)
            {
                row.RemoveAt(Automaton.Size.Width);
            }
            for (var pos = 0; pos < Automaton.Size.Width; pos++)
            {
                // create new ViewModel or update existent one
                var cell = Automaton.GetCell(pos, rowNumber);
                if (pos < row.Count)
                {
                    row[pos].Cell = cell;
                }
                else
                {
                    var cellViewModel = new CellViewModel(Settings, cell);
                    row.Add(cellViewModel);
                }
            }
        }