public ArrangementPageViewModel(InteriorField[,] layout, Chair chairModel, Table tableModel) { this.Rows = layout.GetLength(0); this.Columns = layout.GetLength(1); this.Arrangement = new ObservableCollection<ArrangedFieldViewModel>(); for (int y = 0; y < layout.GetLength(0); y++) for (int x = 0; x < layout.GetLength(1); x++) { this.Arrangement.Add(new ArrangedFieldViewModel((layout[y, x]))); } this.Palettes = new ObservableCollection<string>(new[] { "Light", "Dark" }); this.ChairModel = chairModel; this.TableModel = tableModel; Pathway autoPathway = new Pathway(); Flower autoFlower = new Flower(); foreach (ArrangedFieldViewModel field in this.Arrangement) { if (field?.PlaceHolder?.CanHoldObject(autoFlower) ?? false) field.ArrangeObjectCommand.Execute(autoFlower); else if (field?.PlaceHolder?.CanHoldObject(autoPathway) ?? false) field.ArrangeObjectCommand.Execute(autoPathway); } this.ClearAllCommand = new DelegateCommand((param) => this.ClearAll()); this.FillAllCommand = new DelegateCommand((param) => this.FillAll()); this.RemoveObjectCommand = new DelegateCommand(this.RemoveObject, this.CanRemoveObject); }
public override InteriorField[,] GetLayout() { List<char?> symbolsPool = this.SupportedIdentifiers.Select(c => (char?)c).ToList(); symbolsPool.Add(null); InteriorField[,] result = new InteriorField[rand.Next(1, MaxRows / 5), rand.Next(1, MaxColumns / 5)]; for (int x = 0; x < result.GetLength(0); x++) for (int y = 0; y < result.GetLength(1); y++) { char? currentField = symbolsPool[rand.Next(symbolsPool.Count)]; if (currentField != null) result[x, y] = this.CreateField(currentField.Value); } return result; }