private Vector2 ChoosingStartDrawPoint(int index, Func <IPanelChild, Vector2> calcStarPoint) { if (index > 0) { IPanelChild prevChild = children[index - 1]; return(calcStarPoint(prevChild)); } return(startDrawPointFunc()); }
public void AddChildren(IPanelChild child) { children.Add(child); int index = children.Count - 1; switch (direction) { case Direction.Down: child.StartDrawPointFunc = () => ChoosingStartDrawPoint(index, prevChild => prevChild.StartDrawPointFunc().Translate(prevChild.Margin.X, prevChild.Size.Height + prevChild.Margin.Y)); break; case Direction.Left: child.StartDrawPointFunc = () => ChoosingStartDrawPoint(index, prevChild => prevChild.StartDrawPointFunc().Translate(-prevChild.Margin.X - prevChild.Size.Width, prevChild.Margin.Y)); break; } }