728x90
728x170
▶ MainForm.cs
using System;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 최소 사이드 메뉴 너비
/// </summary>
private const int MINIMUM_SIDE_MENU_WIDTH = 50;
/// <summary>
/// 최대 사이드 메뉴 너비
/// </summary>
private const int MAXIMUM_SIDE_MENU_WIDTH = 200;
/// <summary>
/// 사이드 메뉴 델타 너비
/// </summary>
private const int SIDE_MENU_DELTA_WIDTH = 10;
/// <summary>
/// 사이드 메뉴 너비
/// </summary>
private int sideMenuWidth = 200;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.foldingMenuCheckBox.CheckedChanged += foldingMenuCheckBox_CheckedChanged;
this.foldingMenuTimer.Tick += foldingMenuTimer_Tick;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 메뉴 접기 체크 박스 체크 변경시 처리하기 - foldingMenuCheckBox_CheckedChanged(sender, e)
/// <summary>
/// 메뉴 접기 체크 박스 체크 변경시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void foldingMenuCheckBox_CheckedChanged(object sender, EventArgs e)
{
if(this.foldingMenuCheckBox.Checked == true)
{
this.menu1Button.Text = "M1";
this.menu2Button.Text = "M2";
this.foldingMenuCheckBox.Text = ">";
}
else
{
this.menu1Button.Text = "메뉴 1";
this.menu2Button.Text = "메뉴 2";
this.foldingMenuCheckBox.Text = "<";
}
this.foldingMenuTimer.Start();
}
#endregion
#region 메뉴 접기 타이머 틱 처리하기 - foldingMenuTimer_Tick(sender, e)
/// <summary>
/// 메뉴 접기 타이머 틱 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void foldingMenuTimer_Tick(object sender, EventArgs e)
{
if(this.foldingMenuCheckBox.Checked == true)
{
this.sideMenuWidth -= SIDE_MENU_DELTA_WIDTH;
if(this.sideMenuWidth <= MINIMUM_SIDE_MENU_WIDTH)
{
this.foldingMenuTimer.Stop();
}
}
else
{
this.sideMenuWidth += SIDE_MENU_DELTA_WIDTH;
if(this.sideMenuWidth >= MAXIMUM_SIDE_MENU_WIDTH)
{
this.foldingMenuTimer.Stop();
}
}
this.sideMenuPanel.Width = sideMenuWidth;
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM/.NET5] ImageAttributes 클래스 : 투명 비트맵 구하기 (0) | 2022.05.04 |
---|---|
[C#/WINFORM] Panel 클래스 : 그라디언트 패널 만들기 (0) | 2022.05.02 |
[C#/WINFORM] WEBP 이미지 파일 로드/저장하기 (0) | 2022.03.12 |
[C#/WINFORM] FlashWindowEx API 함수를 사용해 비활성화시 작업 표시줄 깜박이기 (0) | 2022.02.06 |
[C#/WINFORM] TimeZoneInfo 클래스 : ConvertTime 정적 메소드를 사용해 특정 시간대 현재 시간 구하기 (0) | 2022.02.06 |
[C#/WINFORM] FontFamily 클래스 : IsStyleAvailable 메소드를 사용해 스타일 이용 가능 여부 구하기 (0) | 2022.01.16 |
[C#/WINFORM] FontFamily 클래스 : GetName 메소드를 사용해 폰트명 구하기 (0) | 2022.01.16 |
[C#/WINFORM] InstalledFontCollection 클래스 : 설치 폰트명 출력하기 (0) | 2022.01.16 |
[C#/WINFORM] 키움증권 OpenAPI 사용하기 (기능 개선) (0) | 2022.01.14 |
[C#/WINFORM] Scintilla 클래스 : 코드 편집기(Code Editor) 사용하기 (0) | 2022.01.07 |