private static void DetectColumns(IEnumerable<ComponentBoundryPair> components, Grid grid) { var maxX = components.Max(x => x.Boundry.Right); var columnBoundry = new Grid.Boundry(); for (var x = 1; x <= maxX; x++) { if (!CanSliceVertically(x, components)) continue; columnBoundry.Length = x - columnBoundry.Index; grid.AddColumn(columnBoundry); columnBoundry = new Grid.Boundry { Index = x }; } }
private static void DetectRows(IEnumerable<ComponentBoundryPair> components, Grid grid) { var maxY = components.Max(x => x.Boundry.Bottom); var rowBoundry = new Grid.Boundry(); for (var y = 1; y <= maxY; y++) { if (!CanSliceHorizontally(y, components)) continue; rowBoundry.Length = y - rowBoundry.Index; grid.AddRow(rowBoundry); rowBoundry = new Grid.Boundry { Index = y }; } }