UIPanel.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System.Drawing;
  2. using System.Windows.Forms;
  3. using Microsoft.Drawing;
  4. namespace Microsoft.Windows.Forms
  5. {
  6. /// <summary>
  7. /// 虚拟容器控件
  8. /// </summary>
  9. public class UIPanel : UIControl
  10. {
  11. private Image m_BackgroundImage;
  12. /// <summary>
  13. /// 获取或设置背景图
  14. /// </summary>
  15. public virtual Image BackgroundImage
  16. {
  17. get
  18. {
  19. return this.m_BackgroundImage;
  20. }
  21. set
  22. {
  23. if (value != this.m_BackgroundImage)
  24. {
  25. this.m_BackgroundImage = value;
  26. this.Invalidate();
  27. }
  28. }
  29. }
  30. private ImageLayout m_BackgroundImageLayout = ImageLayout.None;
  31. /// <summary>
  32. /// 获取或设置背景图布局方式
  33. /// </summary>
  34. public virtual ImageLayout BackgroundImageLayout
  35. {
  36. get { return this.m_BackgroundImageLayout; }
  37. set
  38. {
  39. if (value != this.m_BackgroundImageLayout)
  40. {
  41. this.m_BackgroundImageLayout = value;
  42. this.Invalidate();
  43. }
  44. }
  45. }
  46. private Color m_BorderColor = DefaultTheme.BorderColor;
  47. /// <summary>
  48. /// 获取或设置边框色
  49. /// </summary>
  50. public virtual Color BorderColor
  51. {
  52. get { return this.m_BorderColor; }
  53. set
  54. {
  55. if (value != this.m_BorderColor)
  56. {
  57. this.m_BorderColor = value;
  58. this.Invalidate();
  59. }
  60. }
  61. }
  62. private BorderVisibleStyle m_BorderVisibleStyle = BorderVisibleStyle.None;
  63. /// <summary>
  64. /// 获取或设置边框可见性
  65. /// </summary>
  66. public virtual BorderVisibleStyle BorderVisibleStyle
  67. {
  68. get
  69. {
  70. return this.m_BorderVisibleStyle;
  71. }
  72. set
  73. {
  74. if (value != this.m_BorderVisibleStyle)
  75. {
  76. this.m_BorderVisibleStyle = value;
  77. this.Invalidate();
  78. }
  79. }
  80. }
  81. /// <summary>
  82. /// 渲染控件
  83. /// </summary>
  84. /// <param name="e">数据</param>
  85. protected override void RenderSelf(PaintEventArgs e)
  86. {
  87. //准备
  88. Graphics g = e.Graphics;
  89. Rectangle rect = RectangleEx.Subtract(this.ClientRectangle, this.Padding);
  90. //渲染
  91. this.Sprite.BackColor = this.BackColor;
  92. this.Sprite.BackgroundImage = this.BackgroundImage;
  93. this.Sprite.BackgroundImageLayout = this.BackgroundImageLayout;
  94. this.Sprite.BorderColor = this.BorderColor;
  95. this.Sprite.BorderVisibleStyle = this.BorderVisibleStyle;
  96. this.Sprite.State = this.State;
  97. this.Sprite.BeginRender(g);
  98. this.Sprite.RenderBackColor(rect);
  99. this.Sprite.RenderBackgroundImage(rect);
  100. this.Sprite.RenderBorder(rect);
  101. this.Sprite.EndRender();
  102. }
  103. }
  104. }