728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 버튼에서 강아지 표시 여부
/// </summary>
private bool isShowPuppyInButton = false;
/// <summary>
/// 픽처 박스에서 강아지 표시 여부
/// </summary>
private bool isShowPuppyInPictureBox = false;
/// <summary>
/// 레이블에서 외계인 표시 여부
/// </summary>
private bool isShowAlienInLabel = false;
/// <summary>
/// 외계인 이미지
/// </summary>
private Image alienImage = null;
/// <summary>
/// 강아지 이미지
/// </summary>
private Image puppuImage = null;
/// <summary>
/// 공사중 이미지
/// </summary>
private Image underConstructionImage = null;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.alienImage = Image.FromFile("Image\\alien.gif" );
this.puppuImage = Image.FromFile("Image\\puppy.gif" );
this.underConstructionImage = Image.FromFile("Image\\under_construction.gif");
this.button.Image = this.underConstructionImage;
this.pictureBox.Image = this.underConstructionImage;
this.label.Image = this.underConstructionImage;
#region 이벤트를 설정한다.
this.button.Click += button_Click;
this.pictureBox.Click += pictueBox_Click;
this.label.Click += label_Click;
#endregion
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 버튼 클릭시 처리하기 - button_Click(sender, e)
/// <summary>
/// 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button_Click(object sender, EventArgs e)
{
this.isShowPuppyInButton = !this.isShowPuppyInButton;
if(this.isShowPuppyInButton)
{
this.button.Image = this.puppuImage;
}
else
{
this.button.Image = this.underConstructionImage;
}
}
#endregion
#region 픽처 박스 클릭시 처리하기 - pictueBox_Click(sender, e)
/// <summary>
/// 픽처 박스 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void pictueBox_Click(object sender, EventArgs e)
{
this.isShowPuppyInPictureBox = !this.isShowPuppyInPictureBox;
if(this.isShowPuppyInPictureBox)
{
this.pictureBox.Image = this.puppuImage;
}
else
{
this.pictureBox.Image = this.underConstructionImage;
}
}
#endregion
#region 레이블 클릭시 처리하기 - label_Click(sender, e)
/// <summary>
/// 레이블 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void label_Click(object sender, EventArgs e)
{
this.isShowAlienInLabel = !this.isShowAlienInLabel;
if(this.isShowAlienInLabel)
{
this.label.Image = this.alienImage;
}
else
{
this.label.Image = this.underConstructionImage;
}
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] PictureBox 클래스 : 이미지 드래그 하기 (0) | 2018.12.11 |
---|---|
[C#/WINFORM] Region 클래스 : 특정 모양을 갖는 폼 만들기 (0) | 2018.12.10 |
[C#/WINFORM] TextureBrush 클래스 사용하기 (0) | 2018.12.10 |
[C#/WINFORM] 영역 채우기(Flood Fill) (0) | 2018.12.10 |
[C#/WINFORM] 유니코드 문자 조회하기 (0) | 2018.12.09 |
[C#/WINFORM] 시어핀스키 가스켓(Sierpinski Gasket) 그리기 (0) | 2018.12.09 |
[C#/WINFORM] 원과 원의 교차 여부 구하기 (0) | 2018.12.09 |
[C#/WINFORM] 직선과 원의 교차 여부 구하기 (0) | 2018.12.09 |
[C#/WINFORM] 타원 버튼 그리기 (0) | 2018.12.09 |
[C#/WINFORM] 피코버 별난 끌개 프랙탈(Pickover Strange Attractor Fractal) 그리기 (0) | 2018.12.09 |
댓글을 달아 주세요