using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace Dongke.WinForm.Controls { /// /// 标准多选按钮 /// [ToolboxBitmap(typeof(CheckBox))] public class ChkCheckBox : CheckBox, IDKControl, IAsyncControl { #region 构造函数 /// /// 标准单选按钮 /// public ChkCheckBox() { base.AutoSize = true; this.BackColor = Color.Transparent; } #endregion #region 重写属性 /// /// 获取或设置一个值,该值指示是否自动调整控件的大小以完整显示其内容 /// [DefaultValue(true)] public override bool AutoSize { get { return base.AutoSize; } set { base.AutoSize = value; } } /// /// 获取或设置控件的背景色 /// [DefaultValue(typeof(Color), "Transparent")] public override Color BackColor { get { return base.BackColor; } set { base.BackColor = value; } } #endregion #region IAsyncControl 成员 #region 成员变量 /// /// 异步处理开始时,控件状态 /// private bool _asyncBeginStatus = false; private bool _asyncBeginFocused = false; #endregion #region 公有方法 /// /// 开始异步处理 /// /// 是否处理焦点 public virtual void BeginAsync(ref bool doFocus) { this._asyncBeginFocused = false; if (doFocus && this.Focused) { this._asyncBeginFocused = true; doFocus = false; } this._asyncBeginStatus = this.Enabled; this.Enabled = false; } /// /// 结束异步处理 /// public virtual void EndAsync() { this.Enabled = this._asyncBeginStatus; if (this._asyncBeginFocused) { this.Focus(); } } #endregion #endregion } }