IEnumerable <GridElement> GetRowElements() { var rowLength = 0; while (ChildrenQueue.Any()) { var element = ChildrenQueue.Peek(); if (rowLength + element.Columns > ColumnsCount) { break; } rowLength += element.Columns; yield return(ChildrenQueue.Dequeue()); } }
internal override SpacePlan Measure(Size availableSpace) { if (!ChildrenQueue.Any()) { return(SpacePlan.FullRender(Size.Zero)); } var lines = Compose(availableSpace); if (!lines.Any()) { return(SpacePlan.Wrap()); } var lineSizes = lines .Select(line => { var size = GetLineSize(line); var widthWithSpacing = size.Width + (line.Count - 1) * HorizontalSpacing; return(new Size(widthWithSpacing, size.Height)); }) .ToList(); var width = lineSizes.Max(x => x.Width); var height = lineSizes.Sum(x => x.Height) + (lines.Count - 1) * VerticalSpacing; var targetSize = new Size(width, height); var isPartiallyRendered = lines.Sum(x => x.Count) != ChildrenQueue.Count; if (isPartiallyRendered) { return(SpacePlan.PartialRender(targetSize)); } return(SpacePlan.FullRender(targetSize)); }