public void Layout() { var piv = new SizeF(PaddingH, PaddingV); var height = SubControls.Select(t => t.subControl.Size.Height).Max(); var newControls = new List <(CanvasControl subControl, SizeF relPivot)>(); for (int i = 0; i < SubControls.Count - 1; i++) { var T = SubControls[i]; var nT = SubControls[i + 1]; newControls.Add((T.subControl, piv)); var W = T.subControl.Size.Width; var nW = nT.subControl.Size.Width; var doubleWidth = piv.Width + W + nW + 4 * PaddingH; if (doubleWidth < Width) //next part fits on same row { piv.Width += W + PaddingH; if (includeSeparators) { newControls.Add((new Separator(this, sThk, height, sColor), piv)); piv.Width += PaddingH; } } else { piv.Width = PaddingH; piv.Height += PaddingV + height; } } newControls.Add((SubControls.Last().subControl, piv)); Size = new SizeF(Width, piv.Height + height + PaddingV); SubControls = newControls; }
public SubControlInterface GetSubControl(GameMode mode) { SubControlInterface subControl; if (!SubControls.TryGetValue(mode, out subControl)) { throw new Exception("SubControl not found!"); } return(subControl); }
public void AddControl(string key, Control control) { SubControls.Add(key, control); control.Parent = this; }