UCPagerControl.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // ***********************************************************************
  2. // Assembly : HZH_Controls
  3. // Created : 08-09-2019
  4. //
  5. // ***********************************************************************
  6. // <copyright file="UCPagerControl.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.Data;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Windows.Forms;
  24. namespace HZH_Controls.Controls
  25. {
  26. /// <summary>
  27. /// Class UCPagerControl.
  28. /// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" />
  29. /// </summary>
  30. /// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" />
  31. [ToolboxItem(true)]
  32. public partial class UCPagerControl : UCPagerControlBase
  33. {
  34. public override int PageCount
  35. {
  36. get
  37. {
  38. return base.PageCount;
  39. }
  40. set
  41. {
  42. base.PageCount = value;
  43. if (PageCount <= 1)
  44. {
  45. ShowBtn(false, false);
  46. }
  47. else
  48. {
  49. ShowBtn(false, PageCount > 1);
  50. }
  51. }
  52. }
  53. public override int PageIndex
  54. {
  55. get
  56. {
  57. return base.PageIndex;
  58. }
  59. set
  60. {
  61. base.PageIndex = value;
  62. if (PageCount <= 1)
  63. {
  64. ShowBtn(false, false);
  65. }
  66. else
  67. {
  68. ShowBtn(false, PageCount > 1);
  69. }
  70. }
  71. }
  72. /// <summary>
  73. /// Initializes a new instance of the <see cref="UCPagerControl" /> class.
  74. /// </summary>
  75. public UCPagerControl()
  76. {
  77. InitializeComponent();
  78. }
  79. /// <summary>
  80. /// Handles the MouseDown event of the panel1 control.
  81. /// </summary>
  82. /// <param name="sender">The source of the event.</param>
  83. /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
  84. private void panel1_MouseDown(object sender, MouseEventArgs e)
  85. {
  86. PreviousPage();
  87. }
  88. /// <summary>
  89. /// Handles the MouseDown event of the panel2 control.
  90. /// </summary>
  91. /// <param name="sender">The source of the event.</param>
  92. /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
  93. private void panel2_MouseDown(object sender, MouseEventArgs e)
  94. {
  95. NextPage();
  96. }
  97. /// <summary>
  98. /// Handles the MouseDown event of the panel3 control.
  99. /// </summary>
  100. /// <param name="sender">The source of the event.</param>
  101. /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
  102. private void panel3_MouseDown(object sender, MouseEventArgs e)
  103. {
  104. FirstPage();
  105. }
  106. /// <summary>
  107. /// Handles the MouseDown event of the panel4 control.
  108. /// </summary>
  109. /// <param name="sender">The source of the event.</param>
  110. /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
  111. private void panel4_MouseDown(object sender, MouseEventArgs e)
  112. {
  113. EndPage();
  114. }
  115. /// <summary>
  116. /// Shows the BTN.
  117. /// </summary>
  118. /// <param name="blnLeftBtn">if set to <c>true</c> [BLN left BTN].</param>
  119. /// <param name="blnRightBtn">if set to <c>true</c> [BLN right BTN].</param>
  120. protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
  121. {
  122. panel1.Visible = panel3.Visible = blnLeftBtn;
  123. panel2.Visible = panel4.Visible = blnRightBtn;
  124. }
  125. }
  126. }