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

CloseRootBoxes() private method

Recursively look at all the controls belonging to the specified control and save the settings for each root box for controls of type ISettings. Then close the root box for controls of type IRootSite. Ideally IRootSite controls should close their root boxes in the OnHandleDestroyed event, but since sometimes IRootSite controls are created but never shown (which means their handle is never created), we have to close the rootboxes here instead.
private CloseRootBoxes ( Control ctrl ) : void
ctrl System.Windows.Forms.Control A main window or any of its descendents
return void
		private void CloseRootBoxes(Control ctrl)
		{
			if (ctrl != null)
			{
				if (ctrl is ISettings)
					((ISettings)ctrl).SaveSettingsNow();

				if (ctrl is IRootSite)
					((IRootSite)ctrl).CloseRootBox();

				foreach (Control childControl in ctrl.Controls)
					CloseRootBoxes(childControl);
			}
		}