using System; using System.ComponentModel; using System.Drawing; namespace Microsoft.Windows.Forms { partial class UIForm { /// /// 获取或设置字体 /// [DefaultValue(typeof(Font), DefaultTheme._Font)] public override Font Font { get { return base.Font; } set { base.Font = value; } } /// /// 获取或设置背景色 /// [DefaultValue(typeof(Font), DefaultTheme._BackColor)] public override Color BackColor { get { return base.BackColor; } set { base.BackColor = value; } } /// /// 获取或设置前景色 /// [DefaultValue(typeof(Font), DefaultTheme._ForeColor)] public override Color ForeColor { get { return base.ForeColor; } set { base.ForeColor = value; } } private State m_State; /// /// 获取状态 /// [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public virtual State State { get { return this.m_State; } protected set { if (value != this.m_State) { this.m_State = value; this.Invalidate(); } } } /// /// 计算状态 /// /// 状态 protected virtual State GetState() { return this.Enabled ? (this.Focused ? State.NormalFocused : State.Normal) : State.Disabled; } /// /// 启用状态改变 /// /// 数据 protected override void OnEnabledChanged(EventArgs e) { base.OnEnabledChanged(e); this.State = this.GetState(); } /// /// 获取焦点 /// /// 数据 protected override void OnGotFocus(EventArgs e) { base.OnGotFocus(e); this.State = this.GetState(); } /// /// 失去焦点 /// /// 数据 protected override void OnLostFocus(EventArgs e) { base.OnLostFocus(e); this.State = this.GetState(); } } }