■ WidgetView 클래스의 QueryControl 이벤트를 사용해 지연 로딩하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
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 } } |