[C#] - 사용자 정의 컨트롤(소스 코드 포함) - 필렛 패널
16287 단어 사용자 정의 컨트롤
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Diagnostics;
using
System.Linq;
using
System.Text;
namespace
myControlLibrary
{
public
partial
class
RoundPanel : System.Windows.Forms.Panel
{
public
RoundPanel()
{
InitializeComponent();
this
.Padding
=
new
System.Windows.Forms.Padding(
0
,
0
,
0
,
0
);
this
.Margin
=
new
System.Windows.Forms.Padding(
0
,
0
,
0
,
0
);
this
.BackgroundImageLayout
=
System.Windows.Forms.ImageLayout.Stretch;
}
//
//
===============================================================================================
private
int
_Radius;
//
///
<summary>
(0 )
</summary>
[Browsable(
true
)]
[Description(
"
(0 )
"
)]
public
int
_setRoundRadius
{
get
{
return
_Radius;
}
set
{
if
(value
<
0
) { _Radius
=
0
; }
else
{ _Radius
=
value; }
base
.Refresh();
}
}
//
public
void
Round(System.Drawing.Region region)
{
//
-----------------------------------------------------------------------------------------------
//
.net ( API)
System.Drawing.Drawing2D.GraphicsPath oPath
=
new
System.Drawing.Drawing2D.GraphicsPath();
int
x
=
0
;
int
y
=
0
;
int
thisWidth
=
this
.Width;
int
thisHeight
=
this
.Height;
int
angle
=
_Radius;
if
(angle
>
0
)
{
System.Drawing.Graphics g
=
CreateGraphics();
oPath.AddArc(x, y, angle, angle,
180
,
90
);
//
oPath.AddArc(thisWidth
-
angle, y, angle, angle,
270
,
90
);
//
oPath.AddArc(thisWidth
-
angle, thisHeight
-
angle, angle, angle,
0
,
90
);
//
oPath.AddArc(x, thisHeight
-
angle, angle, angle,
90
,
90
);
//
oPath.CloseAllFigures();
Region
=
new
System.Drawing.Region(oPath);
}
//
-----------------------------------------------------------------------------------------------
else
{
oPath.AddLine(x
+
angle, y, thisWidth
-
angle, y);
//
oPath.AddLine(thisWidth, y
+
angle, thisWidth, thisHeight
-
angle);
//
oPath.AddLine(thisWidth
-
angle, thisHeight, x
+
angle, thisHeight);
//
oPath.AddLine(x, y
+
angle, x, thisHeight
-
angle);
//
oPath.CloseAllFigures();
Region
=
new
System.Drawing.Region(oPath);
}
}
//
===============================================================================================
public
RoundPanel(IContainer container)
{
container.Add(
this
);
InitializeComponent();
}
protected
override
void
OnPaint(System.Windows.Forms.PaintEventArgs pe)
{
base
.OnPaint(pe);
Round(
this
.Region);
//
}
protected
override
void
OnResize(EventArgs eventargs)
{
base
.OnResize(eventargs);
base
.Refresh();
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
RecycleView 동적으로 item 너비 설정텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.