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