void UpdateGridItemInRange(tk2dUIGridPos start,tk2dUIGridPos end) { if(scrollAxes == Axes.YAxis) { for(int row = start.row;row <= end.row;row++) { for(int col = 0;col < numberOfCols;col++) { System.Predicate<tk2dUIGridViewCell> match = delegate(tk2dUIGridViewCell gridItem) { return (gridItem.Row == row && gridItem.Col == col); }; if(null == m_CellsUsed.Find(match)) { UpdateGridItemAtPos(row,col); } } } } else { for(int col = start.col;col <= end.col;col++) { for(int row = 0;row < numberOfRows;row++) { System.Predicate<tk2dUIGridViewCell> match = delegate(tk2dUIGridViewCell cell) { return (cell.Row == row && cell.Col == col); }; if(null == m_CellsUsed.Find(match)) { UpdateGridItemAtPos(row,col); } } } } }
void ResetUnuseStartAndEnd(tk2dUIGridPos startPos,tk2dUIGridPos endPos) { if(scrollAxes == Axes.YAxis) { //不可以行移除 int row = 0,maxRow = Mathf.Max (numberOfRows - 1, 0); if(m_CellsUsed.Count > 0) { tk2dUIGridViewCell gridItem = m_CellsUsed[0]; row = gridItem.Row; while(row < startPos.row) { MoveCellOutOfSight(gridItem); if(m_CellsUsed.Count > 0) { gridItem = m_CellsUsed[0]; row = gridItem.Row; } else { break; } } if(m_CellsUsed.Count - 1 > 0) { gridItem = m_CellsUsed[m_CellsUsed.Count-1]; row = gridItem.Row; while(row <= maxRow && row >endPos.row) { MoveCellOutOfSight(gridItem); if(m_CellsUsed.Count - 1 > 0) { gridItem = m_CellsUsed[m_CellsUsed.Count-1]; row = gridItem.Row; } else { break; } } } } } else { //不可见列移除 int col = 0,maxCol = Mathf.Max(numberOfCols -1,0); if(m_CellsUsed.Count > 0) { //起始位置不可见部分 tk2dUIGridViewCell cell = m_CellsUsed[0]; col = cell.Col; while(col < startPos.col) { MoveCellOutOfSight(cell); if(m_CellsUsed.Count > 0) { cell = m_CellsUsed[0]; col = cell.Col; } else { break; } } //结束位置不可见部分 if(m_CellsUsed.Count - 1 > 0) { cell = m_CellsUsed[m_CellsUsed.Count - 1]; col = cell.Col; while(col <= maxCol && col > endPos.col) { MoveCellOutOfSight(cell); if(m_CellsUsed.Count - 1 > 0) { cell = m_CellsUsed[m_CellsUsed.Count - 1]; col = cell.Col; } else { break; } } } } } }