54 lines
1.1 KiB
C#
54 lines
1.1 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Windows.Forms;
|
|
|
|
internal class PBtn : Panel
|
|
{
|
|
public string Text2 = "";
|
|
|
|
private bool hov;
|
|
|
|
public event Action Click2;
|
|
|
|
public PBtn()
|
|
{
|
|
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, value: true);
|
|
BackColor = G.Card;
|
|
Cursor = Cursors.Hand;
|
|
}
|
|
|
|
protected override void OnMouseEnter(EventArgs e)
|
|
{
|
|
hov = true;
|
|
Invalidate();
|
|
base.OnMouseEnter(e);
|
|
}
|
|
|
|
protected override void OnMouseLeave(EventArgs e)
|
|
{
|
|
hov = false;
|
|
Invalidate();
|
|
base.OnMouseLeave(e);
|
|
}
|
|
|
|
protected override void OnClick(EventArgs e)
|
|
{
|
|
if (Click2 != null)
|
|
{
|
|
Click2();
|
|
}
|
|
base.OnClick(e);
|
|
}
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
Graphics graphics = e.Graphics;
|
|
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
graphics.Clear(G.Card);
|
|
RectangleF r = new RectangleF(0f, 0f, Width - 1, Height - 1);
|
|
G.Fill(graphics, r, 12f, hov ? G.Mix(G.Acc, Color.White, 0.12f) : G.Acc);
|
|
G.T(graphics, Text2, G.H, Color.White, Width / 2, Height / 2 - 9, StringAlignment.Center);
|
|
}
|
|
}
|