ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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;
        }
    }
}