This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.cs
46 lines (40 loc) · 1.47 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShowTime_DatabseProject
{
public class Utils
{
public static void AgregarBordeInferiorConHover(Button boton, Color colorBorde, int grosor, Color colorFondoHover, Color colorTextoHover)
{
// Variable para guardar el color original del botón
Color colorOriginal = boton.BackColor;
Color colorTextoOriginal = boton.ForeColor;
// Evento Paint para dibujar el borde inferior
boton.Paint += (sender, e) =>
{
int anchoBoton = boton.ClientSize.Width;
int altoBoton = boton.ClientSize.Height;
using (Pen pen = new Pen(colorBorde, grosor))
{
e.Graphics.DrawLine(pen, 0, altoBoton - grosor, anchoBoton, altoBoton - grosor);
}
};
// Evento MouseEnter para cambiar los colores en hover
boton.MouseEnter += (sender, e) =>
{
boton.BackColor = colorFondoHover;
boton.ForeColor = colorTextoHover;
};
// Evento MouseLeave para restaurar los colores originales
boton.MouseLeave += (sender, e) =>
{
boton.BackColor = colorOriginal;
boton.ForeColor = colorTextoOriginal;
};
}
}
}