using System.Windows.Forms;

namespace ChuPiao.AutoPrint.Desktop
{
    //delegate void ControlTextInvoker(Control control, string text);
    delegate void ControlEnableInvoker(Control control, bool state);
    public class BaseUserControl : UserControl
    {
        //public void SetControlText(Control ctl, string txt)
        //{
        //    if(ctl.InvokeRequired)
        //    {
        //        WorkbenchSingleton.SafeThreadCall(new Action<Control, string>(SetControlText), ctl, txt);
        //        return;
        //    }
        //    ctl.Text = txt;

        //}

        protected void SetControlEnable(Control contro, bool state)
        {
            if (contro.InvokeRequired) //ÔÚ¸¨ÖúÏß³ÌÄÚ
            {
                ControlEnableInvoker d = new ControlEnableInvoker(SetControlEnable);
                this.Invoke(d, new object[] { contro, state });
            }
            else
            {
                contro.Enabled = state;
            }
        }
    }
}
