System.Globalization.FormLanguageSwitchSingleton.ScanNonControls C# (CSharp) Method

ScanNonControls() protected method

Scans controls that are not contained by Controls collection, like MenuItems, StatusBarPanels and ColumnHeaders.
protected ScanNonControls ( System containerControl, System resources ) : void
containerControl System
resources System /// ResourceManager used to get localized resources. ///
return void
		protected virtual void ScanNonControls(System.Windows.Forms.ContainerControl containerControl, System.Resources.ResourceManager resources) {
			FieldInfo[] fieldInfo = containerControl.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
			for (int i = 0; i < fieldInfo.Length; i++) {
				object obj = fieldInfo[i].GetValue(containerControl);
				string fieldName = fieldInfo[i].Name;
				if (obj is System.Windows.Forms.MenuItem) {
					System.Windows.Forms.MenuItem menuItem = (System.Windows.Forms.MenuItem)obj;
					menuItem.Enabled        = (bool)(GetSafeValue(resources, fieldName + ".Enabled", menuItem.Enabled));
					menuItem.Shortcut       = (System.Windows.Forms.Shortcut)(GetSafeValue(resources, fieldName + ".Shortcut", menuItem.Shortcut));
					menuItem.ShowShortcut   = (bool)(GetSafeValue(resources, fieldName + ".ShowShortcut", menuItem.ShowShortcut));
					menuItem.Text           = (string)GetSafeValue(resources, fieldName + ".Text", menuItem.Text);
					menuItem.Visible        = (bool)(GetSafeValue(resources, fieldName + ".Visible", menuItem.Visible));
				}
				if (obj is System.Windows.Forms.StatusBarPanel) {
					System.Windows.Forms.StatusBarPanel panel = (System.Windows.Forms.StatusBarPanel)obj;
					panel.Alignment         = (System.Windows.Forms.HorizontalAlignment)(GetSafeValue(resources, fieldName + ".Alignment", panel.Alignment));
					panel.Icon              = (System.Drawing.Icon)(GetSafeValue(resources, fieldName + ".Icon", panel.Icon));
					panel.MinWidth          = (int)(GetSafeValue(resources, fieldName + ".MinWidth", panel.MinWidth));
					panel.Text              = (string)(GetSafeValue(resources, fieldName + ".Text", panel.Text));
					panel.ToolTipText       = (string)(GetSafeValue(resources, fieldName + ".ToolTipText", panel.ToolTipText));
					panel.Width             = (int)(GetSafeValue(resources, fieldName + ".Width", panel.Width));
				}
				if (obj is System.Windows.Forms.ColumnHeader) {
					System.Windows.Forms.ColumnHeader header = (System.Windows.Forms.ColumnHeader)obj;
					header.Text             = (string)(GetSafeValue(resources, fieldName + ".Text", header.Text));
					header.TextAlign        = (System.Windows.Forms.HorizontalAlignment)(GetSafeValue(resources, fieldName + ".TextAlign", header.TextAlign));
					header.Width            = (int)(GetSafeValue(resources, fieldName + ".Width", header.Width));
				}
				if (obj is System.Windows.Forms.ToolBarButton) {
					System.Windows.Forms.ToolBarButton button = (System.Windows.Forms.ToolBarButton)obj;
					button.Enabled          = (bool)(GetSafeValue(resources, fieldName + ".Enabled", button.Enabled));
					button.ImageIndex       = (int)(GetSafeValue(resources, fieldName + ".ImageIndex", button.ImageIndex));
					button.Text             = (string)(GetSafeValue(resources, fieldName + ".Text", button.Text));
					button.ToolTipText      = (string)(GetSafeValue(resources, fieldName + ".ToolTipText", button.ToolTipText));
					button.Visible          = (bool)(GetSafeValue(resources, fieldName + ".Visible", button.Visible));
				}
			}
		}