Here is the class that I Use and my declaration for initialization my problem is that i already made a button on my design. So what will i revise in my code so that, the class that i made will apply to the current button
public Form1()
{
InitializeComponent();
Application.DoEvents();
RoundButton _btn = new RoundButton();
EventHandler myHandler = new EventHandler(_btnLog_Click);
_btnLog = _btn;
}
class RoundButton:Button
{
GraphicsPath GetRoundPath(RectangleF _rect, int radius)
{
float r2 = radius / 2f;
GraphicsPath _gp = new GraphicsPath();
_gp.AddArc(_rect.X, _rect.Y, radius, radius, 180, 90);
_gp.AddLine(_rect.X + r2, _rect.Y, _rect.Width - r2, _rect.Y);
_gp.AddArc(_rect.X + _rect.Width - radius, _rect.Y, radius, radius, 270, 290);
_gp.AddLine(_rect.Width, _rect.Y + r2, _rect.Width, _rect.Height - r2);
_gp.AddArc(_rect.X + _rect.Width - radius,
_rect.Y + _rect.Height - radius, radius, radius, 0, 90);
_gp.AddLine(_rect.Width - r2, _rect.Height, _rect.X + r2, _rect.Height);
_gp.AddArc(_rect.X, _rect.Y + _rect.Height - radius, radius, radius, 90, 90);
_gp.AddLine(_rect.X, _rect.Height - r2, _rect.X, _rect.Y + r2);
_gp.CloseFigure();
return _gp;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
RectangleF _rect = new RectangleF(0, 0, this.Width, this.Height);
GraphicsPath _gp = GetRoundPath(_rect, 1);
this.Region = new Region(_gp);
using (Pen _pen = new Pen(Color.CadetBlue, 1.75f))
{
_pen.Alignment = PenAlignment.Inset;
e.Graphics.DrawPath(_pen, _gp);
}
}
}