UIControl.3.Appearance.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Drawing;
  3. namespace Microsoft.Windows.Forms
  4. {
  5. partial class UIControl
  6. {
  7. private string m_Text;
  8. /// <summary>
  9. /// 获取或设置文本
  10. /// </summary>
  11. public virtual string Text
  12. {
  13. get
  14. {
  15. return this.m_Text;
  16. }
  17. set
  18. {
  19. if (value != this.m_Text)
  20. {
  21. this.m_Text = value;
  22. this.Invalidate();
  23. }
  24. }
  25. }
  26. private Font m_Font = DefaultTheme.Font;
  27. /// <summary>
  28. /// 获取或设置字体
  29. /// </summary>
  30. public virtual Font Font
  31. {
  32. get
  33. {
  34. return this.m_Font;
  35. }
  36. set
  37. {
  38. if (value == null)
  39. throw new ArgumentNullException("value");
  40. if (value != this.m_Font)
  41. {
  42. this.m_Font = value;
  43. this.Invalidate();
  44. }
  45. }
  46. }
  47. private Color m_BackColor = DefaultTheme.BackColor;
  48. /// <summary>
  49. /// 获取或设置背景色
  50. /// </summary>
  51. public virtual Color BackColor
  52. {
  53. get
  54. {
  55. return this.m_BackColor;
  56. }
  57. set
  58. {
  59. if (value != this.m_BackColor)
  60. {
  61. this.m_BackColor = value;
  62. this.Invalidate();
  63. }
  64. }
  65. }
  66. private Color m_ForeColor = DefaultTheme.ForeColor;
  67. /// <summary>
  68. /// 获取或设置前景色
  69. /// </summary>
  70. public virtual Color ForeColor
  71. {
  72. get
  73. {
  74. return this.m_ForeColor;
  75. }
  76. set
  77. {
  78. if (value != this.m_ForeColor)
  79. {
  80. this.m_ForeColor = value;
  81. this.Invalidate();
  82. }
  83. }
  84. }
  85. private State m_State;
  86. /// <summary>
  87. /// 获取状态
  88. /// </summary>
  89. public virtual State State
  90. {
  91. get
  92. {
  93. return this.m_State;
  94. }
  95. protected set
  96. {
  97. if (value != this.m_State)
  98. {
  99. this.m_State = value;
  100. this.Invalidate();
  101. }
  102. }
  103. }
  104. /// <summary>
  105. /// 计算状态
  106. /// </summary>
  107. /// <returns>状态</returns>
  108. protected virtual State GetState()
  109. {
  110. return this.Enabled ? State.Normal : State.Disabled;
  111. }
  112. }
  113. }