private void InitGrid(OrdinalFieldViewModel field) { for (int i = 0; i < field.Size; i++) { AddColumn(); AddRow(); } }
private void FillGrid(OrdinalFieldViewModel field) { int size = field.Size; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { CreateElementViewAt(field, x, y); } } }
private Binding ColorBinding(OrdinalFieldViewModel field, int x, int y) { IValueConverter converter = (IValueConverter)this.Resources["ColorConverter"]; Binding binding = new Binding(nameof(CellViewModel.Background)) { Source = field[x, y], Converter = converter, Mode = BindingMode.OneWay }; return(binding); }
private void DataContextChange(object sender, DependencyPropertyChangedEventArgs e) { OrdinalFieldViewModel field = this.DataContext as OrdinalFieldViewModel; if (field != null) { FillWithCells(field); } else { Clear(); } }
private void CreateElementViewAt(OrdinalFieldViewModel field, int x, int y) { Binding binding = ColorBinding(field, x, y); CreateElementView(binding, x, y); }
private void FillWithCells(OrdinalFieldViewModel field) { InitGrid(field); FillGrid(field); }