using System; using System.Windows.Forms; namespace NeroFiddlesCOM.NET { /// /// Summary description for ControlEnabler. /// public class ControlEnabler { private Form m_form; private bool [] m_bControlStates = null; public ControlEnabler(Form form) { m_form = form; } public void EnableAllControls (bool bEnable) { if (bEnable) { if (m_bControlStates != null) { // Restore state of each form control. // int i = 0; foreach (Control ctrl in m_form.Controls) { ctrl.Enabled = m_bControlStates[i]; } } } else { // Allocate an array big enough to store enable states // for all controls on a form. // m_bControlStates = new bool[m_form.Controls.Count]; // Store states for all controls in an array and // disable each of them. // int i = 0; foreach (Control ctrl in m_form.Controls) { m_bControlStates[i] = ctrl.Enabled; ctrl.Enabled = false; } } } } }