public void InitMap() { using (var sr = new StreamReader("Map.txt")) { string line; Grid = new SquareGrid(15); int i = 0; while ((line = sr.ReadLine()) != null) { var items = line.Split(); for (int j = 0; j < items.Length; j++) { var item = items[j]; var freeCell = new FreeCell(); Grid.Rows[i][j] = freeCell; if (item == "*") { freeCell.IsStart = true; } else if (item[item.Length - 1] == 'w') { freeCell.WordFactor = int.Parse(item.Trim('w')); } else { freeCell.Factor = int.Parse(item); } } i++; } } }
public SquareGrid(int size) { Rows = new ObservableCollection <ObservableCollection <Cell> >(); for (int i = 0; i < size; i++) { var row = new ObservableCollection <Cell>(); for (int j = 0; j < size; j++) { var cell = new FreeCell(); row.Add(cell); } Rows.Add(row); } }