관리자페이지 개발
This commit is contained in:
49
ControlServer/RoundedPanel.cs
Normal file
49
ControlServer/RoundedPanel.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ControlServer
|
||||
{
|
||||
public class RoundedPanel : Panel
|
||||
{
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public int CornerRadius { get; set; } = 30;
|
||||
|
||||
public RoundedPanel()
|
||||
{
|
||||
this.DoubleBuffered = true;
|
||||
// 컨트롤의 배경색이 바뀔 때 다시 그리도록 설정
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// 배경을 투명하게 처리하고 둥근 영역만 남김
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
|
||||
path.AddArc(Width - CornerRadius - 1, 0, CornerRadius, CornerRadius, 270, 90);
|
||||
path.AddArc(Width - CornerRadius - 1, Height - CornerRadius - 1, CornerRadius, CornerRadius, 0, 90);
|
||||
path.AddArc(0, Height - CornerRadius - 1, CornerRadius, CornerRadius, 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
// 영역(Region)을 설정하여 모서리 바깥쪽을 클릭 방지 및 투명 처리
|
||||
this.Region = new Region(path);
|
||||
|
||||
// 배경 채우기
|
||||
using (SolidBrush brush = new SolidBrush(this.BackColor))
|
||||
{
|
||||
e.Graphics.FillPath(brush, path);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnPaint(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user