public Rect GetDockingRect(Size sizeToDock, Margins margins, Alignments alignments) { var marginsCutout = margins.AsThickness(); var withoutMargins = OriginalRect.Deflate(marginsCutout); var finalRect = withoutMargins.AlignChild(sizeToDock, Alignment.End, alignments.Vertical); AccumulatedOffset += sizeToDock.Width; margins.HorizontalMargin = margins.HorizontalMargin.Offset(0, sizeToDock.Width); return finalRect; }
private static void ArrangeToFill(Size availableSize, Margins margins, ILayoutable layoutable) { var containerRect = new Rect(new Point(0,0), availableSize); var marginsCutout = margins.AsThickness(); var withoutMargins = containerRect.Deflate(marginsCutout); var finalSize = GetConstrainedSize(layoutable, withoutMargins); var finalRect = withoutMargins.AlignChild(finalSize, Alignment.Middle, Alignment.Middle); layoutable.Arrange(finalRect); }