internal void ArrangeIconicWindows (bool rearrange_all)
{
Rectangle rect = Rectangle.Empty;
lock_sizing = true;
foreach (Form form in Controls) {
if (form.WindowState != FormWindowState.Minimized)
continue;
MdiWindowManager wm = (MdiWindowManager) form.WindowManager;
if (wm.IconicBounds != Rectangle.Empty && !rearrange_all) {
if (form.Bounds != wm.IconicBounds)
form.Bounds = wm.IconicBounds;
continue;
}
bool success = true;
int startx, starty, currentx, currenty;
rect.Size = wm.IconicSize;
startx = 0;
starty = ClientSize.Height - rect.Height;
currentx = startx;
currenty = starty;
do {
rect.X = currentx;
rect.Y = currenty;
success = true;
foreach (Form form2 in Controls) {
if (form2 == form || form2.window_state != FormWindowState.Minimized)
continue;
if (form2.Bounds.IntersectsWith(rect)) {
success = false;
break;
}
}
if (!success) {
currentx += rect.Width;
if (currentx + rect.Width > Right) {
currentx = startx;
currenty -= rect.Height;
}
}
} while (!success);
wm.IconicBounds = rect;
form.Bounds = wm.IconicBounds;
}
lock_sizing = false;
}