// not used but kept as utility function public DashboardCellPosition GetMaxRowColumnIndex() { DashboardCellPosition maxIndexPos = new DashboardCellPosition(0, 0); for (int i = 0; i < CellsContainer.Children.Count; i++) { DashboardCellPosition cellPosition = ((ICellUC)(CellsContainer.Children[i])).GetDashboardCellConfig().CellPosition_; if (cellPosition.ColIndex_ > maxIndexPos.ColIndex_) { maxIndexPos.ColIndex_ = cellPosition.ColIndex_; } if (cellPosition.RowIndex_ > maxIndexPos.RowIndex_) { maxIndexPos.RowIndex_ = cellPosition.RowIndex_; } } return(maxIndexPos); }
public void SyncRowColDefinitionsWithCells() { List <DashboardCellPosition> cellPositions = new List <DashboardCellPosition>(); // iterate through each cell in the cells container for (int cell_iter = 0; cell_iter < CellsContainer.Children.Count; cell_iter++) { ICellUC cellUC = (ICellUC)CellsContainer.Children[cell_iter]; IDashboardCellConfig dashboardCellConfig = cellUC.GetDashboardCellConfig(); DashboardCellPosition cellPosition = dashboardCellConfig.CellPosition_; // manipulate cell position to avoid cell position conflicts by pushing the cell position down by one row if (cellPositions.Exists(x => x.RowIndex_ == cellPosition.RowIndex_ && x.ColIndex_ == cellPosition.ColIndex_)) { // get the maximum row Index int maxRowIndex = (from pos in cellPositions select pos.RowIndex_).Max(); //modify the rowIndex to avoid duplicates cellPosition.RowIndex_ = maxRowIndex + 1; cellUC.GetDashboardCellConfig().CellPosition_ = cellPosition; } cellPositions.Add(cellPosition); } int maxRows = 0; int maxCols = 0; if (cellPositions.Count > 0) { maxRows = (from pos in cellPositions select pos.RowIndex_).Max() + 1; maxCols = (from pos in cellPositions select pos.ColIndex_).Max() + 1; } // Add adequate number of row and column definitions // Find rows deficit int rowDeficit = maxRows - CellsContainer.RowDefinitions.Count(); int colDeficit = maxCols - CellsContainer.ColumnDefinitions.Count(); // Do addition or deletion of row definitions for Row Grids if (rowDeficit > 0) { // add deficit rows for (int i = 0; i < rowDeficit; i++) { CellsContainer.RowDefinitions.Add(GetNewRowDefinition()); } } else if (rowDeficit < 0) { // delete excess rows for (int i = 0; i < -rowDeficit; i++) { CellsContainer.RowDefinitions.RemoveAt(0); } } if (colDeficit > 0) { // add deficit columns for (int i = 0; i < colDeficit; i++) { CellsContainer.ColumnDefinitions.Add(GetNewColDefinition()); } } else if (colDeficit < 0) { // delete excess columns for (int i = 0; i < -colDeficit; i++) { CellsContainer.ColumnDefinitions.RemoveAt(0); } } }
public CellPosChangeReqArgs(DashboardCellPosition dashboardCellPosition_) { DashboardCellPosition_ = dashboardCellPosition_; }