YButton.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace MAutoUpdate.Control
  9. {
  10. public partial class YButton : Label
  11. {
  12. private Boolean isColorChange = true;
  13. private Boolean isFontChange = false;
  14. public Boolean IsFontChange
  15. {
  16. get { return isFontChange; }
  17. set { isFontChange = value; }
  18. }
  19. public Boolean IsColorChange
  20. {
  21. get { return isColorChange; }
  22. set { isColorChange = value; }
  23. }
  24. private Color normalColor = Color.FromArgb(56, 95, 170);
  25. public Color NormalColor
  26. {
  27. get { return normalColor; }
  28. set { normalColor = value; }
  29. }
  30. private Color moveColor = Color.FromArgb(128, 156, 211);
  31. public Color MoveColor
  32. {
  33. get { return moveColor; }
  34. set { moveColor = value; }
  35. }
  36. private Color moveFontColor = Color.FromArgb(128, 156, 211);
  37. public Color MoveFontColor
  38. {
  39. get { return moveFontColor; }
  40. set { moveFontColor = value; }
  41. }
  42. private Color normalFontColor = Color.FromArgb(128, 156, 211);
  43. public Color NormalFontColor
  44. {
  45. get { return normalFontColor; }
  46. set { normalFontColor = value; }
  47. }
  48. public Image EnterImage { get; set; }
  49. public YButton()
  50. : base()
  51. {
  52. this.Size = new Size(61, 23);
  53. this.ForeColor = Color.FromArgb(240, 240, 240);
  54. this.BackColor = normalColor;
  55. this.TextAlign = ContentAlignment.MiddleCenter;
  56. this.AutoSize = false;
  57. }
  58. protected override void OnMouseEnter(EventArgs e)
  59. {
  60. if (isColorChange)
  61. {
  62. this.BackColor = moveColor;
  63. }
  64. if (isFontChange)
  65. {
  66. this.ForeColor =this.moveFontColor;
  67. }
  68. base.OnMouseEnter(e);
  69. }
  70. protected override void OnMouseLeave(EventArgs e)
  71. {
  72. if (isColorChange)
  73. {
  74. this.BackColor = normalColor;
  75. }
  76. if (isFontChange)
  77. {
  78. this.ForeColor = this.normalFontColor;
  79. }
  80. base.OnMouseLeave(e);
  81. }
  82. protected override void OnPaint(PaintEventArgs e)
  83. {
  84. base.OnPaint(e);
  85. }
  86. }
  87. }