ImageButton.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace IntelligentControlForsx.MyControls
  9. {
  10. public class ImageButton : Button
  11. {
  12. public ImageButton()
  13. {
  14. FlatStyle = FlatStyle.Flat;//样式
  15. ForeColor = Color.Transparent;//前景
  16. BackColor = Color.Transparent;//去背景
  17. FlatAppearance.BorderSize = 0;//去边线
  18. FlatAppearance.MouseOverBackColor = Color.Transparent;//鼠标经过
  19. FlatAppearance.MouseDownBackColor = Color.Transparent;//鼠标按下
  20. Size = new System.Drawing.Size(142, 38);
  21. Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  22. ForeColor = System.Drawing.Color.White;
  23. BackgroundImage = global::IntelligentControlForsx.Properties.Resources.btn_station1;
  24. }
  25. protected override void OnPaint(PaintEventArgs e)
  26. {
  27. base.OnPaint(e);
  28. }
  29. protected override void OnMouseHover(EventArgs e)
  30. {
  31. FlatAppearance.BorderSize = 1;
  32. }
  33. protected override void OnMouseLeave(EventArgs e)
  34. {
  35. FlatAppearance.BorderSize = 0;
  36. }
  37. }
  38. }