double GetAverageLineInfo( Size availableSize, VirtualizingLayoutContext context, FlowLayoutState flowState, double avgCountInLine) { // default to 1 item per line with 0 size double avgLineSize = 0; avgCountInLine = 1; MUX_ASSERT(context.ItemCount > 0); if (flowState.TotalLinesMeasured == 0) { var tmpElement = context.GetOrCreateElementAt(0, ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle); var desiredSize = flowState.FlowAlgorithm.MeasureElement(tmpElement, 0, availableSize, context); context.RecycleElement(tmpElement); int estimatedCountInLine = Math.Max(1, (int)(Minor(availableSize) / Minor(desiredSize))); flowState.OnLineArranged(0, estimatedCountInLine, Major(desiredSize), context); flowState.SpecialElementDesiredSize = desiredSize; } avgCountInLine = Math.Max(1.0, flowState.TotalItemsPerLine / flowState.TotalLinesMeasured); avgLineSize = Math.Round(flowState.TotalLineSize / flowState.TotalLinesMeasured); return(_uno_lastKnownAverageLineSize = avgLineSize); }
double GetAverageElementSize( Size availableSize, VirtualizingLayoutContext context, StackLayoutState stackLayoutState) { double averageElementSize = 0; if (context.ItemCount > 0) { if (stackLayoutState.TotalElementsMeasured == 0) { var tmpElement = context.GetOrCreateElementAt(0, ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle); stackLayoutState.FlowAlgorithm.MeasureElement(tmpElement, 0, availableSize, context); context.RecycleElement(tmpElement); } MUX_ASSERT(stackLayoutState.TotalElementsMeasured > 0); averageElementSize = Math.Round(stackLayoutState.TotalElementSize / stackLayoutState.TotalElementsMeasured); } return(averageElementSize); }