첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

TestProject.zip
0.01MB

▶ 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
그리드형(광고전용)
Posted by icodebroker
,