public void AddCell(int rowIndex, int columnIndex) { if (_currentRowIndex == -1) { _currentRowIndex = rowIndex; _firstColumnIndex = columnIndex; _lastColumnIndex = columnIndex; } else { if (_currentRowIndex == rowIndex && _lastColumnIndex + 1 == columnIndex) { _lastColumnIndex = columnIndex; } else { // cell does not fit on end of current row if (_currentRectangleGroup == null) { _currentRectangleGroup = new BlankCellRectangleGroup(_currentRowIndex, _firstColumnIndex, _lastColumnIndex); } else { if (!_currentRectangleGroup.AcceptRow(_currentRowIndex, _firstColumnIndex, _lastColumnIndex)) { _rectangleGroups.Add(_currentRectangleGroup); _currentRectangleGroup = new BlankCellRectangleGroup(_currentRowIndex, _firstColumnIndex, _lastColumnIndex); } } _currentRowIndex = rowIndex; _firstColumnIndex = columnIndex; _lastColumnIndex = columnIndex; } } }
public bool ContainsCell(int rowIndex, int columnIndex) { for (int i = _rectangleGroups.Count - 1; i >= 0; i--) { BlankCellRectangleGroup bcrg = (BlankCellRectangleGroup)_rectangleGroups[i]; if (bcrg.ContainsCell(rowIndex, columnIndex)) { return(true); } } if (_currentRectangleGroup != null && _currentRectangleGroup.ContainsCell(rowIndex, columnIndex)) { return(true); } if (_currentRowIndex != -1 && _currentRowIndex == rowIndex) { if (_firstColumnIndex <= columnIndex && columnIndex <= _lastColumnIndex) { return(true); } } return(false); }
public void AddCell(int rowIndex, int columnIndex) { if (_currentRowIndex == -1) { _currentRowIndex = rowIndex; _firstColumnIndex = columnIndex; _lastColumnIndex = columnIndex; } else { if (_currentRowIndex == rowIndex && _lastColumnIndex + 1 == columnIndex) { _lastColumnIndex = columnIndex; } else { // cell does not fit on end of current row if (_currentRectangleGroup == null) { _currentRectangleGroup = new BlankCellRectangleGroup(_currentRowIndex, _firstColumnIndex, _lastColumnIndex); } else { if (!_currentRectangleGroup.AcceptRow(_currentRowIndex, _firstColumnIndex, _lastColumnIndex)) { _rectangleGroups.Add(_currentRectangleGroup); _currentRectangleGroup = new BlankCellRectangleGroup(_currentRowIndex, _firstColumnIndex, _lastColumnIndex); } } _currentRowIndex = rowIndex; _firstColumnIndex = columnIndex; _lastColumnIndex = columnIndex; } } }