+ }
+ case MdiLayout.ArrangeIcons:
+ ArrangeIconicWindows (true);
+ break;
+ case MdiLayout.TileHorizontal:
+ case MdiLayout.TileVertical: {
+ // First count number of windows to tile
+ int total = 0;
+ for (int i = 0; i < Controls.Count; i++) {
+ Form form = Controls [i] as Form;
+
+ if (form == null)
+ continue;
+
+ if (!form.Visible)
+ continue;
+
+ if (form.WindowState == FormWindowState.Minimized)
+ continue;
+
+ total++;
+ }
+ if (total <= 0)
+ return;
+
+ // Calculate desired height and width
+ Size newSize;
+ Size offset;
+ if (value == MdiLayout.TileHorizontal) {
+ newSize = new Size (ClientSize.Width, ClientSize.Height / total);
+ offset = new Size (0, newSize.Height);
+ } else {
+ newSize = new Size (ClientSize.Width / total, ClientSize.Height);
+ offset = new Size (newSize.Width, 0);
+ }
+
+ // Loop again and set the size and location.
+ Point nextLocation = Point.Empty;
+
+ for (int i = 0; i < Controls.Count; i++) {
+ Form form = Controls [i] as Form;
+
+ if (form == null)
+ continue;
+
+ if (!form.Visible)
+ continue;
+
+ if (form.WindowState == FormWindowState.Minimized)
+ continue;
+
+ form.Size = newSize;
+ form.Location = nextLocation;
+ nextLocation += offset;
+ }
+
+ break;
+ }