private void Cell_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == LayerCellViewModel.ValuePropertyName) { LayerCellViewModel _cell = (LayerCellViewModel)sender; bool _allIsChecked = true; bool _allIsUnchecked = true; foreach (LayerView _layerView in this.FLayers) { LayerCellViewModel _layerCell = _layerView.ViewModel.Cells[_cell.X, _cell.Y]; if (!_layerCell.LayerCellValue) { _allIsChecked = false; } if (_layerCell.LayerCellValue) { _allIsUnchecked = false; } } LayerCellViewModel _commonCell = this.FCommonLayer.ViewModel.Cells[_cell.X, _cell.Y]; if (_allIsChecked && !_commonCell.LayerCellValue) { _commonCell.LayerCellValue = true; } if (_allIsUnchecked && _commonCell.LayerCellValue) { _commonCell.LayerCellValue = false; } } }
private void LayerCell_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (this.FHandled) { return; } if (e.PropertyName == LayerCellViewModel.ValuePropertyName) { LayerCellViewModel _layerCell = (LayerCellViewModel)sender; int _shapeCellValue = 0; for (int k = 0; k < this.FHeight; k++) { if (this.FCells[_layerCell.X, _layerCell.Y, k].LayerCellValue) { _shapeCellValue += 1 << k; } } if (this.FData[_layerCell.X, _layerCell.Y].ShapeCellValue != (byte)_shapeCellValue) { this.FData[_layerCell.X, _layerCell.Y].ShapeCellValue = (byte)_shapeCellValue; NotifyPropertyChanged(ShapePropertyName); } } }
private void CommonCell_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == LayerCellViewModel.ValuePropertyName) { LayerCellViewModel _commonCell = (LayerCellViewModel)sender; if (_commonCell.LayerCellValue) { this.ViewModel.Data[_commonCell.X, _commonCell.Y].ShapeCellValue = (byte)((1 << this.LayersNumber) - 1); } else { this.ViewModel.Data[_commonCell.X, _commonCell.Y].ShapeCellValue = 0; } } }
private void ProcessCell(LayerCellViewModel aCell, TileViewModel aTile) { TileGeometry _tile = this.FTiles.Where(x => x.Tile == aTile).SingleOrDefault(); int _tileSize = JsdTile.GetProfileXSize(aTile.IsHighDefenition); int _tileBottom = aTile.TileIsOnRoof ? JsdTile.GetProfileZSize(aTile.IsHighDefenition) : 0; if (aCell.LayerCellValue) { _tile.AddCube(aCell.X, aCell.Y, aCell.Z, _tileSize, _tileBottom); this.ViewModel.FilledPositionCount++; } else { _tile.RemoveCube(aCell.X, aCell.Y, aCell.Z, _tileSize, _tileBottom); this.ViewModel.FilledPositionCount--; } _tile.UpdateTileGeometry(); }
public ShapeViewModel(bool aIsHighDefenition) { this.FSize = aIsHighDefenition ? JsdTile.MinSize * 2 : JsdTile.MinSize; this.FHeight = aIsHighDefenition ? JsdTile.MinHeight * 2 : JsdTile.MinHeight; this.FCells = new LayerCellViewModel[this.FSize, this.FSize, this.FHeight]; this.FLayers = new LayerViewModel[this.FHeight]; for (int k = 0; k < this.FHeight; k++) { this.FLayers[k] = new LayerViewModel(aIsHighDefenition, k); for (int i = 0; i < this.FSize; i++) { for (int j = 0; j < this.FSize; j++) { LayerCellViewModel _cell = this.FLayers[k].Cells[i, j]; this.SetLayerCell(_cell, k); } } } this.Shape = new byte[this.FSize * this.FSize]; }
void Cell_PropertyChanged(object sender, PropertyChangedEventArgs e) { LayerCellViewModel _cell = (LayerCellViewModel)sender; this.ProcessCell(_cell, this.ViewModel.Structure.SelectedTile); }
public void SetLayerCell(LayerCellViewModel aCell, int aLayerNumber) { aCell.PropertyChanged += LayerCell_PropertyChanged; this.FCells[aCell.X, aCell.Y, aLayerNumber] = aCell; }