public void DelRow() { //if (!_isCellsStandalone) return; DeselectBlocks(); var cells = RowViewModelList.Last().CellsCollection; RowViewModelList.Remove(RowViewModelList.Last()); foreach (var cell in cells) { cell.CellData.RowNum--; RowViewModelList.Last().CellsCollection.Add(cell); } RowViewModelList.Last().UpdateFacade(); RowViewModelList.Last().UpdateDirection(); RowViewModelList.Last().UpdateDoorDirection(); RowViewModelList.Last().UpdateBusPositions(); RowViewModelList.Last().UpdateCellPanel(); ControlsCollection.Remove(_controlsCollection.Last(x => x.GetType() == typeof(RowBlock))); UpdateAll(); StageSave(); }
public bool AddRowCheck() { if (_isCellsStandalone) { return(false); } return(RowViewModelList.Count > 0 && RowViewModelList.Count < 6 && RowViewModelList.Last().CellsCollection .ToList().Count >= 2); }
public void AddRow() { if ((RowViewModelList.Count != 0 && !_secondsRow) || (RowViewModelList.Count == 2)) { return; } DeselectBlocks(); var rowData = new RowData(); var rowBlock = new RowBlock(this); var rowBlockViewModel = (VMRowBlock)rowBlock.DataContext; rowBlockViewModel.SetParams(this, rowData); rowBlockViewModel.PropertyChanged += RowViewModel_PropertyChanged; var facade = Facade.Down; var direction = Direction.LeftToRight; var doorDirection = DoorDirection.Left; if (RowViewModelList.Count == 0) { foreach (var cell in _cellDataList) { cell.RowNum = 1; } rowBlockViewModel.CreateCells(_cellDataList); } else { var lastCells = RowViewModelList.Last(); List <CellData> cellDatas = new List <CellData>(); int count = _cellDataList.Count; for (int i = 0; i < count; i++) { CellData cellData = new CellData(_cellDataList[i]); cellData.SystemNum = cellData.SystemNum + count; cellData.IndexNum = cellData.IndexNum + count + 1; cellData.RowNum = cellData.RowNum + 1; cellData.UserNum = cellData.IndexNum.ToString(); cellDatas.Add(cellData); _cellDataList.Add(cellData); } rowBlockViewModel.CreateCells(cellDatas); rowBlockViewModel.DirectY = AreaHeight - cellDatas.Max(x => x.Depth) / Constants.MainScale; if (RowViewModelList.Last().Facade == Facade.Down) { facade = Facade.Up; } if (RowViewModelList.Last().Direction == Direction.LeftToRight) { direction = Direction.RightToLeft; } if (RowViewModelList.Last().DoorDirection == DoorDirection.Left) { doorDirection = DoorDirection.Right; } RowViewModelList.Last().UpdateCellPanel(); } rowBlockViewModel.UpdateFacade(facade); rowBlockViewModel.UpdateDirection(direction); rowBlockViewModel.UpdateDoorDirection(doorDirection); rowBlockViewModel.UpdateBusPositions(); rowBlockViewModel.UpdateCellPanel(); RowViewModelList.Add(rowBlockViewModel); ControlsCollection.Add(rowBlock); UpdateRowPosition(RowViewModelList.Count > 1 ? RowViewModelList[RowViewModelList.Count - 2] : null, rowBlockViewModel); UpdateAll(); StageSave(); }