UCPanelQuote.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // ***********************************************************************
  2. // Assembly : HZH_Controls
  3. // Created : 2019-10-15
  4. //
  5. // ***********************************************************************
  6. // <copyright file="UCPanelQuote.cs">
  7. // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
  8. // </copyright>
  9. //
  10. // Blog: https://www.cnblogs.com/bfyx
  11. // GitHub:https://github.com/kwwwvagaa/NetWinformControl
  12. // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
  13. //
  14. // If you use this code, please keep this note.
  15. // ***********************************************************************
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.Drawing;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Windows.Forms;
  23. namespace HZH_Controls.Controls
  24. {
  25. /// <summary>
  26. /// Class UCPanelQuote.
  27. /// Implements the <see cref="System.Windows.Forms.Panel" />
  28. /// </summary>
  29. /// <seealso cref="System.Windows.Forms.Panel" />
  30. public class UCPanelQuote : Panel
  31. {
  32. /// <summary>
  33. /// The border color
  34. /// </summary>
  35. private Color borderColor = LineColors.Light;
  36. /// <summary>
  37. /// Gets or sets the color of the border.
  38. /// </summary>
  39. /// <value>The color of the border.</value>
  40. [Description("边框颜色"), Category("自定义")]
  41. public Color BorderColor
  42. {
  43. get { return borderColor; }
  44. set
  45. {
  46. borderColor = value;
  47. this.Invalidate();
  48. }
  49. }
  50. /// <summary>
  51. /// The left color
  52. /// </summary>
  53. private Color leftColor = StatusColors.Danger;
  54. /// <summary>
  55. /// Gets or sets the color of the left.
  56. /// </summary>
  57. /// <value>The color of the left.</value>
  58. [Description("左侧颜色"), Category("自定义")]
  59. public Color LeftColor
  60. {
  61. get { return leftColor; }
  62. set
  63. {
  64. leftColor = value;
  65. this.Invalidate();
  66. }
  67. }
  68. /// <summary>
  69. /// Initializes a new instance of the <see cref="UCPanelQuote"/> class.
  70. /// </summary>
  71. public UCPanelQuote()
  72. : base()
  73. {
  74. Padding = new Padding(5, 1, 1, 1);
  75. }
  76. /// <summary>
  77. /// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
  78. /// </summary>
  79. /// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
  80. protected override void OnPaint(PaintEventArgs e)
  81. {
  82. base.OnPaint(e);
  83. e.Graphics.SetGDIHigh();
  84. e.Graphics.DrawLines(new Pen(borderColor), new Point[]
  85. {
  86. new Point(e.ClipRectangle.Left,e.ClipRectangle.Top),
  87. new Point(e.ClipRectangle.Right-1,e.ClipRectangle.Top),
  88. new Point(e.ClipRectangle.Right-1,e.ClipRectangle.Bottom-1),
  89. new Point(e.ClipRectangle.Left,e.ClipRectangle.Bottom-1),
  90. new Point(e.ClipRectangle.Left,e.ClipRectangle.Top)
  91. });
  92. e.Graphics.FillRectangle(new SolidBrush(leftColor), new Rectangle(0, 0, 5, this.Height));
  93. }
  94. }
  95. }