1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Windows.Forms;
- namespace LYFZ.NeroDiscBurn.NET
- {
- /// <summary>
- /// Summary description for ControlEnabler.
- /// </summary>
- 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;
- }
- }
- }
- }
- }
|