private static double ArrangeControlGroup(RibbonItemGroup itemGroup, Size finalSize, double offset) { var orientation = itemGroup.Orientation; switch (orientation) { case Orientation.Vertical: var lineWidth = itemGroup.EnumerateItems().Max(i => i.DesiredSize.Width); return(offset + PanelHelper.ArrangeStackLine(itemGroup.EnumerateItems(), orientation, offset, 0, lineWidth, finalSize.Height / 3).Indirect); case Orientation.Horizontal: return(offset + PanelHelper.ArrangeStackLine(itemGroup.EnumerateItems(), orientation, 0, offset, finalSize.Height, null).Direct); default: throw new ArgumentOutOfRangeException(); } }