첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainForm.cs

using System;
using System.ComponentModel;

using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : XtraForm
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 메뉴 항목 1
        /// </summary>
        private BarSubItem menuItem1;

        /// <summary>
        /// 메뉴 항목 2
        /// </summary>
        private BarButtonItem menuItem2;

        /// <summary>
        /// 메뉴 항목 3
        /// </summary>
        private BarCheckItem menuItem3;

        /// <summary>
        /// 메뉴 항목 4
        /// </summary>
        private BarSubItem menuItem4;

        /// <summary>
        /// 메뉴 항목 5
        /// </summary>
        private BarStaticItem menuItem5;

        /// <summary>
        /// 메뉴 항목 6
        /// </summary>
        private BarEditItem menuItem6;

        /// <summary>
        /// 메뉴 에디터 6
        /// </summary>
        private RepositoryItemTextEdit menuEditor6;

        /// <summary>
        /// 메뉴 항목 7
        /// </summary>
        private BarEditItem menuItem7;

        /// <summary>
        /// 메뉴 에디터 7
        /// </summary>
        private RepositoryItemDateEdit menuEditor7;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            ((ISupportInitialize)(this.barManager)).BeginInit();

            menuEditor6 = GetRepositoryItemTextEdit(this.barManager, "menuEditor6");
            menuEditor7 = GetRepositoryItemDateEdit(this.barManager, "menuEditor7");

            menuItem1 = GetBarSubItem   (this.barManager, 0, "menuItem1", "Menu1", -1             );
            menuItem2 = GetBarButtonItem(this.barManager, 1, "menuItem2", "Menu2", -1             );
            menuItem3 = GetBarCheckItem (this.barManager, 2, "menuItem3", "Menu3", -1, true       );
            menuItem4 = GetBarSubItem   (this.barManager, 3, "menuItem4", "Menu4", -1             );
            menuItem5 = GetBarStaticItem(this.barManager, 4, "menuItem5", "Menu5", -1             );
            menuItem6 = GetBarEditItem  (this.barManager, 5, "menuItem6", "Menu6", -1, menuEditor6);
            menuItem7 = GetBarEditItem  (this.barManager, 6, "menuItem7", "Menu7", -1, menuEditor7);
            
            menuItem7.Width = 120;

            menuItem1.LinksPersistInfo.AddRange
            (
                new LinkPersistInfo[]
                {
                    new LinkPersistInfo(menuItem2),
                    new LinkPersistInfo(menuItem3),
                    new LinkPersistInfo(menuItem4),
                    new LinkPersistInfo(menuItem5),
                    new LinkPersistInfo(menuItem6)
                }
            );

            menuItem4.LinksPersistInfo.AddRange
            (
                new LinkPersistInfo[]
                {
                    new LinkPersistInfo(menuItem7)
                }
            );

            this.menuBar.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(menuItem1) });

            ((ISupportInitialize)(barManager)).EndInit();
        }

        #endregion

        #region 텍스트 편집자 저장소 항목 구하기 - GetRepositoryItemTextEdit(barManager, name)

        /// <summary>
        /// 텍스트 편집자 저장소 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="name">명칭</param>
        /// <returns>텍스트 편집자 저장소 항목 객체</returns>
        private RepositoryItemTextEdit GetRepositoryItemTextEdit(BarManager barManager, string name)
        {
            RepositoryItemTextEdit repositoryItemTextEdit = new RepositoryItemTextEdit();

            repositoryItemTextEdit.Name       = name;
            repositoryItemTextEdit.AutoHeight = false;

            barManager.RepositoryItems.Add(repositoryItemTextEdit);

            return repositoryItemTextEdit;
        }

        #endregion
        #region 일자 편집자 저장소 항목 구하기 - GetRepositoryItemDateEdit(barManager, name)

        /// <summary>
        /// 일자 편집자 저장소 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="name">명칭</param>
        /// <returns>일자 편집자 저장소 항목</returns>
        private RepositoryItemDateEdit GetRepositoryItemDateEdit(BarManager barManager, string name)
        {
            RepositoryItemDateEdit repositoryItemDateEdit = new RepositoryItemDateEdit();

            repositoryItemDateEdit.Name       = name;
            repositoryItemDateEdit.AutoHeight = false;

            barManager.RepositoryItems.Add(repositoryItemDateEdit);

            return repositoryItemDateEdit;
        }

        #endregion

        #region 바 하위 항목 구하기 - GetBarSubItem(barManager, id, name, caption, imageIndex)

        /// <summary>
        /// 바 하위 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="id">ID</param>
        /// <param name="name">명칭</param>
        /// <param name="caption">제목</param>
        /// <param name="imageIndex">이미지 인덱스</param>
        /// <returns>바 하위 항목</returns>
        private BarSubItem GetBarSubItem(BarManager barManager, int id, string name, string caption, int imageIndex)
        {
            BarSubItem barSubItem = new BarSubItem();

            barSubItem.Id         = id;
            barSubItem.Name       = name;
            barSubItem.Caption    = caption;
            barSubItem.ImageIndex = imageIndex;
            barSubItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;

            barManager.Items.Add(barSubItem);

            return barSubItem;
        }

        #endregion
        #region 바 버튼 항목 구하기 - GetBarButtonItem(barManager, id, name, caption, imageIndex)

        /// <summary>
        /// 바 버튼 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="id">ID</param>
        /// <param name="name">명칭</param>
        /// <param name="caption">제목</param>
        /// <param name="imageIndex">이미지 인덱스</param>
        /// <returns>바 버튼 항목</returns>
        private BarButtonItem GetBarButtonItem(BarManager barManager, int id, string name, string caption, int imageIndex)
        {
            BarButtonItem barButtonItem = new BarButtonItem();

            barButtonItem.Id         = id;
            barButtonItem.Name       = name;
            barButtonItem.Caption    = caption;
            barButtonItem.ImageIndex = imageIndex;
            barButtonItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;

            barManager.Items.Add(barButtonItem);

            return barButtonItem;
        }

        #endregion
        #region 바 체크 항목 구하기 - GetBarCheckItem(barManager, id, name, caption, imageIndex, isChecked)

        /// <summary>
        /// 바 체크 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="id">ID</param>
        /// <param name="name">명칭</param>
        /// <param name="caption">제목</param>
        /// <param name="imageIndex">이미지 인덱스</param>
        /// <param name="isChecked">체크 여부</param>
        /// <returns>바 체크 항목</returns>
        private BarCheckItem GetBarCheckItem(BarManager barManager, int id, string name, string caption, int imageIndex, bool isChecked)
        {
            BarCheckItem barCheckItem = new BarCheckItem();

            barCheckItem.Id         = id;
            barCheckItem.Name       = name;
            barCheckItem.Caption    = caption;
            barCheckItem.ImageIndex = imageIndex;
            barCheckItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;
            barCheckItem.Checked    = isChecked;

            barManager.Items.Add(barCheckItem);

            return barCheckItem;
        }

        #endregion
        #region 바 고정 항목 구하기 - GetBarStaticItem(barManager, id, name, caption, imageIndex)

        /// <summary>
        /// 바 고정 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="id">ID</param>
        /// <param name="name">명칭</param>
        /// <param name="caption">제목</param>
        /// <param name="imageIndex">이미지 인덱스</param>
        /// <returns>바 고정 항목</returns>
        private BarStaticItem GetBarStaticItem(BarManager barManager, int id, string name, string caption, int imageIndex)
        {
            BarStaticItem barStaticItem = new BarStaticItem();

            barStaticItem.Id            = id;
            barStaticItem.Name          = name;
            barStaticItem.Caption       = caption;
            barStaticItem.ImageIndex    = imageIndex;
            barStaticItem.PaintStyle    = BarItemPaintStyle.CaptionGlyph;

            barManager.Items.Add(barStaticItem);

            return barStaticItem;
        }

        #endregion
        #region 바 편집 항목 구하기 - GetBarEditItem(barManager, id, name, caption, imageIndex, item)

        /// <summary>
        /// 바 편집 항목 구하기
        /// </summary>
        /// <param name="barManager">바 관리자</param>
        /// <param name="id">ID</param>
        /// <param name="name">명칭</param>
        /// <param name="caption">제목</param>
        /// <param name="imageIndex">이미지 인덱스</param>
        /// <param name="item">저장소 항목</param>
        /// <returns>바 편집 항목</returns>
        private BarEditItem GetBarEditItem(BarManager barManager, int id, string name, string caption, int imageIndex, RepositoryItem item)
        {
            BarEditItem barEditItem = new BarEditItem();

            barEditItem.Id         = id;
            barEditItem.Name       = name;
            barEditItem.Caption    = caption;
            barEditItem.ImageIndex = imageIndex;
            barEditItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;
            barEditItem.Edit       = item;

            barManager.Items.Add(barEditItem);

            return barEditItem;
        }

        #endregion
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker

댓글을 달아 주세요