SlotSizer GetNextSizer() { if (sizerCursor == sizers.Count) { var sizer = new SlotSizer(); sizers.Add(sizer); AddVisualChild(sizer); } return(sizers[sizerCursor++]); }
void ArrangeSlot(SlotData slotData, Point upperLeft, Size finalSize) { UVHelper uv = UVHelper.CreateInstance(slotData.Slot.Orientation); Point runningUpperLeft = upperLeft; double maxU = uv.U(runningUpperLeft) + uv.U(finalSize); bool addSizer = false; Slot previousSlot = null; foreach (var child in slotData.Slot.Children) { if (addSizer) { SlotSizer sizer = GetNextSizer(); sizer.SizeDirection = slotData.Slot.Orientation; sizer.Slot1 = previousSlot; sizer.Slot2 = child; sizer.Measure(uv.Size(SlotSpacing, uv.V(finalSize))); sizer.Arrange(new Rect(uv.Point(uv.U(runningUpperLeft), uv.V(runningUpperLeft)), uv.Size(SlotSpacing, uv.V(finalSize)))); runningUpperLeft = uv.Point(Math.Min(maxU, uv.U(runningUpperLeft) + SlotSpacing), uv.V(runningUpperLeft)); } var childSlot = slotTable[InternalGetSlotName(child)]; var childFinalSize = uv.Size(Math.Min(uv.U(finalSize), uv.U(childSlot.FinalSize)), uv.V(finalSize)); ArrangeSlot(childSlot, runningUpperLeft, childFinalSize); runningUpperLeft = uv.Point(Math.Min(maxU, uv.U(runningUpperLeft) + uv.U(childFinalSize)), uv.V(runningUpperLeft)); addSizer = (SlotSpacing > 0); previousSlot = child; } if (slotData.Elements != null) { foreach (UIElement element in slotData.Elements) { element.Arrange(new Rect(upperLeft, finalSize)); } } slotData.Slot.ActualSize = finalSize; slotData.Slot.UpperLeft = upperLeft; }