■ SplitContainer 클래스 : 스플리터 설정하기
------------------------------------------------------------------------------------------------------------------------
▶ MainForm.cs
using System; using System.Drawing; using System.Windows.Forms;
namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent();
#region 이벤트를 설정한다.
Resize += Form_Resize; this.closeLeftButton.Click += closeLeftButton_Click; this.left25Button.Click += left25Button_Click; this.left50Button.Click += left50Button_Click; this.left75Button.Click += left75Button_Click; this.closeRightButton.Click += closeRightButton_Click;
#endregion }
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private
#region 폼 크기 조정시 처리하기 - Form_Resize(sender, e)
/// <summary> /// 폼 크기 조정시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void Form_Resize(object sender, EventArgs e) { this.closeLeftButton.Location = new Point(0, 5); this.left25Button.Location = new Point((int)(ClientSize.Width * 0.25), 5); this.left50Button.Location = new Point((int)(ClientSize.Width * 0.50), 5); this.left75Button.Location = new Point((int)(ClientSize.Width * 0.75), 5); this.closeRightButton.Location = new Point(ClientSize.Width - this.closeRightButton.Width, 5); }
#endregion #region 왼쪽 패널 닫기 버튼 클릭시 처리하기 - closeLeftButton_Click(sender, e)
/// <summary> /// 왼쪽 패널 닫기 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void closeLeftButton_Click(object sender, EventArgs e) { this.SplitContainer.Panel1Collapsed = true; }
#endregion #region 왼쪽 패널 25% 버튼 클릭시 처리하기 - left25Button_Click(sender, e)
/// <summary> /// 왼쪽 패널 25% 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void left25Button_Click(object sender, EventArgs e) { this.SplitContainer.Panel1Collapsed = false; this.SplitContainer.Panel2Collapsed = false; this.SplitContainer.SplitterDistance = (int)(this.SplitContainer.ClientSize.Width * 0.25); }
#endregion #region 왼쪽 패널 50% 버튼 클릭시 처리하기 - left50Button_Click(sender, e)
/// <summary> /// 왼쪽 패널 50% 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void left50Button_Click(object sender, EventArgs e) { this.SplitContainer.Panel1Collapsed = false; this.SplitContainer.Panel2Collapsed = false; this.SplitContainer.SplitterDistance = (int)(SplitContainer.ClientSize.Width * 0.5); }
#endregion #region 왼쪽 패널 75% 버튼 클릭시 처리하기 - left75Button_Click(sender, e)
/// <summary> /// 왼쪽 패널 75% 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void left75Button_Click(object sender, EventArgs e) { this.SplitContainer.Panel1Collapsed = false; this.SplitContainer.Panel2Collapsed = false; this.SplitContainer.SplitterDistance = (int)(SplitContainer.ClientSize.Width * 0.75); }
#endregion #region 오른쪽 패널 닫기 버튼 클릭시 처리하기 - closeRightButton_Click(sender, e)
/// <summary> /// 오른쪽 패널 닫기 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void closeRightButton_Click(object sender, EventArgs e) { this.SplitContainer.Panel2Collapsed = true; }
#endregion } }
|
------------------------------------------------------------------------------------------------------------------------
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 별난 끌개 프랙탈(Strange Attractor Fractal) 그리기 (0) | 2018.12.02 |
---|---|
[C#/WINFORM] 이미지 사각형 선택하기 (0) | 2018.12.02 |
[C#/WINFORM] 이미지 파일명에 따라 적절한 포맷으로 이미지 저장하기 (0) | 2018.12.02 |
[C#/WINFORM] 투명 폼 만들기 (0) | 2018.12.02 |
[C#/WINFORM] ListBox 클래스, TextBox 클래스 : 탭 설정하기 (0) | 2018.12.02 |
[C#/WINFORM] SplitContainer 클래스 : 스플리터 설정하기 (0) | 2018.12.02 |
[C#/WINFORM] 망델브로 프랙탈(Mandelbrot Fractal) 그리기 (0) | 2018.12.02 |
[C#/WINFORM] 반즐리 고사리 프랙탈(Barnsley Fern Fractal) 그리기 (0) | 2018.12.01 |
[C#/WINFORM] 브다브로 프랙탈(Buddhabrot Fractal) 그리기 (0) | 2018.12.01 |
[C#/WINFORM] 힐버트 곡선(Hilbert Curve) 그리기 (0) | 2018.12.01 |
[C#/WINFORM] Bitmap 클래스 : MakeTransparent 메소드를 사용해 투명 배경색 설정하기 (0) | 2018.11.30 |
댓글을 달아 주세요