SIL.FieldWorks.Common.Framework.FwApp.CascadeWindows C# (CSharp) Method

CascadeWindows() public method

Cascade the windows from top left and resize them to fill 2/3 of the screen area (or the minimum allowable size).
public CascadeWindows ( Form wndCurr ) : void
wndCurr System.Windows.Forms.Form Current Window (i.e. window whose menu was used to issue the /// Cascaede command.
return void
		public void CascadeWindows(Form wndCurr)
		{
			CheckDisposed();

			// Get the screen in which to cascade.
			Screen scrn = Screen.FromControl(wndCurr);

			Rectangle rcScrnAdjusted = ScreenUtils.AdjustedWorkingArea(scrn);
			Rectangle rcUpperLeft = rcScrnAdjusted;
			rcUpperLeft.Width = CascadeSize(rcUpperLeft.Width, wndCurr.MinimumSize.Width);
			rcUpperLeft.Height = CascadeSize(rcUpperLeft.Height, wndCurr.MinimumSize.Height);
			Rectangle rc = rcUpperLeft;

			foreach (Form wnd in MainWindows)
			{
				// Ignore windows that are on other screens or which are minimized.
				if (scrn.WorkingArea == Screen.FromControl(wnd).WorkingArea &&
					wnd != wndCurr &&
					wnd.WindowState != FormWindowState.Minimized)
				{
					if (wnd.WindowState == FormWindowState.Maximized)
						wnd.WindowState = FormWindowState.Normal;

					wnd.DesktopBounds = rc;
					wnd.Activate();
					rc.Offset(SystemInformation.CaptionHeight, SystemInformation.CaptionHeight);
					if (!rcScrnAdjusted.Contains(rc))
					{
						rc = rcUpperLeft;
					}
				}
			}

			// Make the active window the last one and activate it.
			if (wndCurr.WindowState == FormWindowState.Maximized)
				wndCurr.WindowState = FormWindowState.Normal;
			wndCurr.DesktopBounds = rc;
			wndCurr.Activate();
		}