UIControl.2Behaviour.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. namespace Microsoft.Windows.Forms
  3. {
  4. partial class UIControl
  5. {
  6. private string m_Name;
  7. /// <summary>
  8. /// 获取或设置控件名称
  9. /// </summary>
  10. public string Name
  11. {
  12. get
  13. {
  14. return this.m_Name;
  15. }
  16. set
  17. {
  18. this.m_Name = value;
  19. }
  20. }
  21. private bool m_Visible = true;
  22. /// <summary>
  23. /// 获取或设置控件是否可见
  24. /// </summary>
  25. public bool Visible
  26. {
  27. get
  28. {
  29. return this.m_Visible;
  30. }
  31. set
  32. {
  33. if (value != this.m_Visible)
  34. {
  35. this.m_Visible = value;
  36. this.SetBounds();
  37. this.Invalidate();
  38. }
  39. }
  40. }
  41. private bool m_Enabled = true;
  42. /// <summary>
  43. /// 获取或设置控件是否启用
  44. /// </summary>
  45. public bool Enabled
  46. {
  47. get
  48. {
  49. return this.m_Enabled;
  50. }
  51. set
  52. {
  53. if (value != this.m_Enabled)
  54. {
  55. this.m_Enabled = value;
  56. this.Invalidate();
  57. }
  58. }
  59. }
  60. private bool m_Capture;
  61. /// <summary>
  62. /// 获取或设置控件是否捕获鼠标
  63. /// </summary>
  64. public bool Capture
  65. {
  66. get
  67. {
  68. return this.m_Capture;
  69. }
  70. set
  71. {
  72. if (value != this.Capture)
  73. {
  74. this.m_Capture = value;
  75. this.State = this.GetState();
  76. if (value)
  77. this.OnEnter(EventArgs.Empty);
  78. else
  79. this.OnLeave(EventArgs.Empty);
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// 显示控件
  85. /// </summary>
  86. public void Show()
  87. {
  88. this.Visible = true;
  89. }
  90. /// <summary>
  91. /// 隐藏控件
  92. /// </summary>
  93. public void Hide()
  94. {
  95. this.Visible = false;
  96. }
  97. }
  98. }