728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
#region 이벤트를 설정한다.
Load += Form_Load;
this.button.Click += button_Click;
#endregion
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 폼 로드시 처리하기 - Form_Load(sender, e)
/// <summary>
/// 폼 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_Load(object sender, EventArgs e)
{
Point[] pointArray =
{
new Point( 20, 60),
new Point(140, 60),
new Point(140, 20),
new Point(220, 100),
new Point(140, 180),
new Point(140, 140),
new Point( 20, 140)
};
GraphicsPath graphicsPath = new GraphicsPath(FillMode.Winding);
graphicsPath.AddPolygon(pointArray);
Region region = new Region(graphicsPath);
this.button.Region = region;
this.button.SetBounds
(
button.Location.X,
button.Location.Y,
pointArray[3].X + 5,
pointArray[4].Y + 5
);
}
#endregion
#region 버튼 클릭시 처리하기 - button_Click(sender, e)
/// <summary>
/// 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button_Click(object sender, EventArgs e)
{
MessageBox.Show("Clicked!");
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 마우스 드래그시 고무밴드 상자(Rubber Band Box) 표시하기 (0) | 2018.12.08 |
---|---|
[C#/WINFORM] 포인트 리스트를 둘러싸는 원 구하기 (0) | 2018.12.05 |
[C#/WINFORM] 2개 직선 사이 최단거리 구하기 (0) | 2018.12.05 |
[C#/WINFORM] 2개 직선의 교차 여부 구하기 (0) | 2018.12.05 |
[C#/WINFORM] 하이포트로코이드(Hypotrochoid) 그리기 (0) | 2018.12.05 |
[C#/WINFORM] Button 클래스 : 버튼 모양 설정하기 (0) | 2018.12.03 |
[C#/WINFORM] 다각형 처리하기 (0) | 2018.12.03 |
[C#/WINFORM] 시어핀스키 곡선(Sierpinski Curve) 그리기 (0) | 2018.12.03 |
[C#/WINFORM] 별난 끌개 프랙탈(Strange Attractor Fractal) 그리기 (0) | 2018.12.02 |
[C#/WINFORM] 포인트 리스트를 둘러싸는 외곽선(Convex Hull) 구하기 (0) | 2018.12.02 |
[C#/WINFORM] 이미지 사각형 선택하기 (0) | 2018.12.02 |
댓글을 달아 주세요