internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints) {
#if DEBUG
if (CompModSwitches.FlowLayout.TraceInfo) {
Debug.WriteLine("FlowLayout::GetPreferredSize("
+ "container=" + container.ToString() + ", "
+ "proposedConstraints=" + proposedConstraints.ToString() + ")");
Debug.Indent();
}
#endif
Rectangle measureBounds = new Rectangle(new Point(0, 0), proposedConstraints);
Size prefSize = xLayout(container, measureBounds, /* measureOnly = */ true);
if(prefSize.Width > proposedConstraints.Width || prefSize.Height> proposedConstraints.Height) {
// Controls measured earlier than a control which couldn't be fit to constraints may
// shift around with the new bounds. We need to make a 2nd pass through the
// controls using these bounds which are gauranteed to fit.
measureBounds.Size = prefSize;
prefSize = xLayout(container, measureBounds, /* measureOnly = */ true);
}
#if DEBUG
if (CompModSwitches.FlowLayout.TraceInfo) {
Debug.Unindent();
Debug.WriteLine("GetPreferredSize returned " + prefSize);
}
#endif
return prefSize;
}