UIForm.3.Appearance.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using System.ComponentModel;
  3. using System.Drawing;
  4. namespace Microsoft.Windows.Forms
  5. {
  6. partial class UIForm
  7. {
  8. /// <summary>
  9. /// 获取或设置字体
  10. /// </summary>
  11. [DefaultValue(typeof(Font), DefaultTheme._Font)]
  12. public override Font Font
  13. {
  14. get
  15. {
  16. return base.Font;
  17. }
  18. set
  19. {
  20. base.Font = value;
  21. }
  22. }
  23. /// <summary>
  24. /// 获取或设置背景色
  25. /// </summary>
  26. [DefaultValue(typeof(Font), DefaultTheme._BackColor)]
  27. public override Color BackColor
  28. {
  29. get
  30. {
  31. return base.BackColor;
  32. }
  33. set
  34. {
  35. base.BackColor = value;
  36. }
  37. }
  38. /// <summary>
  39. /// 获取或设置前景色
  40. /// </summary>
  41. [DefaultValue(typeof(Font), DefaultTheme._ForeColor)]
  42. public override Color ForeColor
  43. {
  44. get
  45. {
  46. return base.ForeColor;
  47. }
  48. set
  49. {
  50. base.ForeColor = value;
  51. }
  52. }
  53. private State m_State;
  54. /// <summary>
  55. /// 获取状态
  56. /// </summary>
  57. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  58. public virtual State State
  59. {
  60. get
  61. {
  62. return this.m_State;
  63. }
  64. protected set
  65. {
  66. if (value != this.m_State)
  67. {
  68. this.m_State = value;
  69. this.Invalidate();
  70. }
  71. }
  72. }
  73. /// <summary>
  74. /// 计算状态
  75. /// </summary>
  76. /// <returns>状态</returns>
  77. protected virtual State GetState()
  78. {
  79. return this.Enabled ? (this.Focused ? State.NormalFocused : State.Normal) : State.Disabled;
  80. }
  81. /// <summary>
  82. /// 启用状态改变
  83. /// </summary>
  84. /// <param name="e">数据</param>
  85. protected override void OnEnabledChanged(EventArgs e)
  86. {
  87. base.OnEnabledChanged(e);
  88. this.State = this.GetState();
  89. }
  90. /// <summary>
  91. /// 获取焦点
  92. /// </summary>
  93. /// <param name="e">数据</param>
  94. protected override void OnGotFocus(EventArgs e)
  95. {
  96. base.OnGotFocus(e);
  97. this.State = this.GetState();
  98. }
  99. /// <summary>
  100. /// 失去焦点
  101. /// </summary>
  102. /// <param name="e">数据</param>
  103. protected override void OnLostFocus(EventArgs e)
  104. {
  105. base.OnLostFocus(e);
  106. this.State = this.GetState();
  107. }
  108. }
  109. }