private bool IsValidLocation(Cell aCell, System.Drawing.Point aLocation) {
// rowspan not beyond last column
if ( aLocation.X < rows.Count ) { // if false : new location is already at new, not-yet-created area so no check
if ((aLocation.Y + aCell.Colspan) > columns) {
return false;
}
int difx = ((rows.Count - aLocation.X) > aCell.Rowspan) ? aCell.Rowspan : rows.Count - aLocation.X;
int dify = ((columns - aLocation.Y) > aCell.Colspan) ? aCell.Colspan : columns - aLocation.Y;
// no other content at cells targetted by rowspan/colspan
for (int i=aLocation.X; i < (aLocation.X + difx); i++) {
for (int j=aLocation.Y; j < (aLocation.Y + dify); j++) {
if ( ((Row) rows[i]).IsReserved(j) == true ) {
return false;
}
}
}
}
else {
if ((aLocation.Y + aCell.Colspan) > columns) {
return false;
}
}
return true;
}