첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

■ WidgetView 클래스 : QueryControl 이벤트를 사용해 지연 로딩하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip



MainForm.cs

 

 

using System.Collections.Generic;

 

using DevExpress.Utils;

using DevExpress.XtraEditors;

using DevExpress.XtraBars.Docking2010.Views;

using DevExpress.XtraBars.Docking2010.Views.Widget;

 

namespace TestProject

{

    /// <summary>

    /// 메인 폼

    /// </summary>

    public partial class MainForm : XtraForm

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region Field

 

        /// <summary>

        /// 회사명 딕셔너리

        /// </summary>

        private Dictionary<string, string> companyNameDictionary = new Dictionary<string, string>();

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainForm()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainForm()

        {

            InitializeComponent();

 

            this.companyNameDictionary.Add("AAPL", "Apple Inc."                 );

            this.companyNameDictionary.Add("YHOO", "Yahoo! Inc."                );

            this.companyNameDictionary.Add("CSCO", "Cisco Systems Inc."         );

            this.companyNameDictionary.Add("ADBE", "Adobe Systems Inc."         );

            this.companyNameDictionary.Add("BAC" , "Bank of America Corporation");

            this.companyNameDictionary.Add("DELL", "Dell Inc."                  );

            this.companyNameDictionary.Add("NVDA", "NVIDIA Corporation"         );

            this.companyNameDictionary.Add("HPQ" , "Hewlete-Packard Company"    );

 

            StackGroup stackGroup1 = GetStackGroup(null, LengthUnitType.Pixel, 250);

            StackGroup stackGroup2 = GetStackGroup(null, LengthUnitType.Pixel, 250);

            StackGroup stackGroup3 = GetStackGroup(null, LengthUnitType.Pixel, 250);

 

            AddStackGroup(this.widgetView, stackGroup1);

            AddStackGroup(this.widgetView, stackGroup2);

            AddStackGroup(this.widgetView, stackGroup3);

 

            Document document1 = GetDocument("document1", "AAPL", 200, DefaultBoolean.False);

            Document document2 = GetDocument("document2", "ADBE", 200, DefaultBoolean.False);

            Document document3 = GetDocument("document3", "CSCO", 200, DefaultBoolean.False);

            Document document4 = GetDocument("document4", "YHOO", 200, DefaultBoolean.False);

            Document document5 = GetDocument("document5", "NVDA", 200, DefaultBoolean.False);

 

            AddDocument(this.widgetView, document1);

            AddDocument(this.widgetView, document2);

            AddDocument(this.widgetView, document3);

            AddDocument(this.widgetView, document4);

            AddDocument(this.widgetView, document5);

 

            AddDocument(stackGroup1, document1);

            AddDocument(stackGroup1, document2);

            AddDocument(stackGroup2, document3);

            AddDocument(stackGroup3, document4);

            AddDocument(stackGroup3, document5);

 

            this.widgetView.QueryControl += widgetView_QueryControl;

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        //////////////////////////////////////////////////////////////////////////////// Event

 

        #region 위젯 뷰 컨트롤 질의하기 - widgetView_QueryControl(sender, e)

 

        /// <summary>

        /// 위젯 뷰 컨트롤 질의하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void widgetView_QueryControl(object sender, QueryControlEventArgs e)

        {

            string title = this.companyNameDictionary[e.Document.Caption];

 

            SummaryControl control = new SummaryControl();

 

            control.Title = title;

 

            e.Control = control;

 

            DocumentControl documentControl = new DocumentControl();

 

            documentControl.Title = title;

 

            (e.Document as Document).MaximizedControl = documentControl;

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////// Function

 

        #region 스택 그룹 구하기 - GetStackGroup(caption, lengthUnitType, unitValue)

 

        /// <summary>

        /// 스택 그룹 구하기

        /// </summary>

        /// <param name="caption">제목</param>

        /// <param name="lengthUnitType">길이 단위 타입</param>

        /// <param name="unitValue">단위 값</param>

        /// <returns>스택 그룹</returns>

        private StackGroup GetStackGroup(string caption, LengthUnitType lengthUnitType, double unitValue)

        {

            StackGroup stackGroup = new StackGroup();

 

            stackGroup.Caption          = caption;

            stackGroup.Length.UnitType  = lengthUnitType;

            stackGroup.Length.UnitValue = unitValue;

 

            return stackGroup;

        }

 

        #endregion

        #region 스택 그룹 추가하기 - AddStackGroup(widgetView, stackGroup)

 

        /// <summary>

        /// 스택 그룹 추가하기

        /// </summary>

        /// <param name="widgetView">위젯 뷰</param>

        /// <param name="stackGroup">스택 그룹</param>

        private void AddStackGroup(WidgetView widgetView, StackGroup stackGroup)

        {

            widgetView.StackGroups.Add(stackGroup);

        }

 

        #endregion

        #region 문서 구하기 - GetDocument(controlName, caption, height, allowClose)

 

        /// <summary>

        /// 문서 구하기

        /// </summary>

        /// <param name="controlName">컨트롤명</param>

        /// <param name="caption">제목</param>

        /// <param name="height">높이</param>

        /// <param name="allowClose">닫기 허용 여부</param>

        /// <returns>문서</returns>

        private Document GetDocument(string controlName, string caption, int height, DefaultBoolean allowClose)

        {

            Document document = new Document();

 

            document.ControlName           = controlName;

            document.Caption               = caption;

            document.Height                = height;

            document.Properties.AllowClose = allowClose;

 

            return document;

        }

 

        #endregion

        #region 문서 추가하기 - AddDocument(stackGroup, document)

 

        /// <summary>

        /// 문서 추가하기

        /// </summary>

        /// <param name="stackGroup">스택 그룹</param>

        /// <param name="document">문서</param>

        private void AddDocument(StackGroup stackGroup, Document document)

        {

            stackGroup.Items.Add(document);

        }

 

        #endregion

        #region 문서 추가하기 - AddDocument(baseView, document)

 

        /// <summary>

        /// 문서 추가하기

        /// </summary>

        /// <param name="baseView">베이스 뷰</param>

        /// <param name="document">문서</param>

        private void AddDocument(BaseView baseView, Document document)

        {

            baseView.Documents.Add(document);

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

728x90
반응형
Posted by 사용자 icodebroker

댓글을 달아 주세요