private void layout ()
{
NSView[] subviews = simpleView.Subviews;
PointF curPoint;
switch (LayoutStyle){
case Layout.ColumnLayout:
curPoint = new PointF(simpleView.Bounds.Size.Width / 2.0f, 0.0f);
foreach (NSView subview in subviews) {
RectangleF frame = new RectangleF(curPoint.X - BOX_WIDTH /2.0f, curPoint.Y, BOX_WIDTH, BOX_HEIGHT);
animateView(subview, frame);
curPoint.Y += frame.Size.Height + SEPARATION;
}
break;
case Layout.RowLayout:
curPoint = new PointF(0.0f , simpleView.Bounds.Size.Height / 2.0f);
foreach (NSView subview in subviews) {
RectangleF frame = new RectangleF(curPoint.X, curPoint.Y - BOX_HEIGHT /2.0f, BOX_WIDTH, BOX_HEIGHT);
animateView(subview, frame);
curPoint.X += frame.Size.Width + SEPARATION;
}
break;
case Layout.GridLayout:
int viewsPerSide = (int)Math.Ceiling( Math.Sqrt(subviews.Count()) );
int idx = 0;
foreach (NSView subview in subviews) {
RectangleF frame = new RectangleF(curPoint.X, curPoint.Y, BOX_WIDTH, BOX_HEIGHT);
animateView(subview, frame);
curPoint.X += frame.Size.Width + SEPARATION;
if (++idx % viewsPerSide == 0) {
curPoint.X = 0;
curPoint.Y += BOX_HEIGHT + SEPARATION;
}
}
break;
}
}