using HotelPms.Share.Windows.Util;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Drawing.Drawing2D;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace HotelPms.Share.Windows.Component
|
{
|
public class RoundButton : System.Windows.Forms.Control
|
{
|
private StringFormat m_StringFormat = new StringFormat(StringFormatFlags.NoWrap);
|
|
public RoundButton()
|
{
|
//base.BackColor = Color.Transparent;
|
//BackColor = Color.Black;
|
//ForeColor = Color.White;
|
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
|
SetStyle(ControlStyles.Opaque, false);
|
m_StringFormat.Alignment = StringAlignment.Center;
|
m_StringFormat.LineAlignment = StringAlignment.Center;
|
}
|
|
|
protected override void Dispose(bool disposing)
|
{
|
//img.Dispose();
|
m_StringFormat.Dispose();
|
base.Dispose(disposing);
|
}
|
|
protected override void OnPaint(PaintEventArgs e)
|
{
|
base.OnPaint(e);
|
|
//if (img == null)
|
//{
|
// img = Image.FromFile(Application.StartupPath + @"\avatar5.png");
|
// imgEllipse = GdiPlus.CutEllipse(img, new Rectangle(0, 0, img.Size.Width, img.Size.Height), img.Size);
|
//}
|
|
|
//GdiPlus.FillRoundRectangle(e.Graphics, Brushes.DarkBlue, (RectangleF)ClientRectangle, 24);
|
//e.Graphics.DrawImage(imgEllipse, new Rectangle(5, 5, ClientRectangle.Size.Height - 10, ClientRectangle.Size.Height - 10));
|
//GdiPlus.DrawRoundRectangle(e.Graphics, Pens.Red, (RectangleF)ClientRectangle, 15);
|
|
|
//TextRenderer.DrawText();
|
//TextRenderer.MeasureText()
|
}
|
|
private static GraphicsPath CreateRoundRectangle(Rectangle rectangle, int radius)
|
{
|
radius += 10;
|
GraphicsPath path = new GraphicsPath();
|
int l = rectangle.Left;
|
int t = rectangle.Top;
|
int w = rectangle.Width;
|
int h = rectangle.Height;
|
int d = radius << 1;
|
path.AddArc(l, t, d, d, 180, 90); // topleft
|
path.AddLine(l + radius, t, l + w - radius, t); // top
|
path.AddArc(l + w - d, t, d, d, 270, 90); // topright
|
path.AddLine(l + w, t + radius, l + w, t + h - radius); // right
|
path.AddArc(l + w - d, t + h - d, d, d, 0, 90); // bottomright
|
path.AddLine(l + w - radius, t + h, l + radius, t + h); // bottom
|
path.AddArc(l, t + h - d, d, d, 90, 90); // bottomleft
|
path.AddLine(l, t + h - radius, l, t + radius); // left
|
path.CloseFigure();
|
return path;
|
}
|
}
|
}
|