■ GridControl 클래스에서 인스턴트 피드백 모드를 사용하는 방법을 보여준다. (XPO)
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" Width="800" Height="600" Title="인스턴트 피드백 모드 구현하기 (XPO)" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew" /> </Grid> </Window> |
▶ MainWindow.xaml.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 |
using System; using System.Windows; using DevExpress.Xpo; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeDataAccessLayer(); GenerateTestData(100000); InitializeComponent(); XPInstantFeedbackSource source = new XPInstantFeedbackSource(typeof(TestObject)); source.ResolveSession += source_ResolveSession; source.DismissSession += source_DismissSession; this.gridControl.ItemsSource = source; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private //////////////////////////////////////////////////////////////////////////////// Event #region 세션 Resolve 처리하기 - source_ResolveSession(sender, e) /// <summary> /// 세션 Resolve 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void source_ResolveSession(object sender, ResolveSessionEventArgs e) { e.Session = new UnitOfWork(); } #endregion #region 세션 Dismiss 처리하기 - source_DismissSession(sender, e) /// <summary> /// 세션 Dismiss 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void source_DismissSession(object sender, ResolveSessionEventArgs e) { IDisposable disposable = e.Session as IDisposable; if(disposable != null) { disposable.Dispose(); } } #endregion //////////////////////////////////////////////////////////////////////////////// Function #region 데이터 액세스 레이어 초기화 하기 - InitializeDataAccessLayer() /// <summary> /// 데이터 액세스 레이어 초기화 하기 /// </summary> private static void InitializeDataAccessLayer() { XpoDefault.Session = null; XpoDefault.DataLayer = XpoDefault.GetDataLayer ( DevExpress.Xpo.DB.AccessConnectionProvider.GetConnectionString("test.mdb"), DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema ); } #endregion #region 테스트 데이터 생성하기 - GenerateTestData(recordCount) /// <summary> /// 테스트 데이터 생성하기 /// </summary> /// <param name="recordCount">레코드 수</param> private void GenerateTestData(int recordCount) { using(UnitOfWork unitOfWork = new UnitOfWork()) { if(unitOfWork.FindObject<TestObject>(null) != null) { return; } for(int i = 0; i < recordCount; i++) { TestObject testObject = new TestObject(unitOfWork) { HasAttachment = false, Sent = DateTime.Now, Subject = string.Format("Subject {0}", i) }; } unitOfWork.CommitChanges(); } } #endregion } } |
▶ TestObject.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 |
using System; using DevExpress.Xpo; namespace TestProject { /// <summary> /// 테스트 객체 /// </summary> public class TestObject : XPObject { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 주제 /// </summary> private string subject; /// <summary> /// 송신 일시 /// </summary> private DateTime sendTime; /// <summary> /// 첨부 여부 /// </summary> private bool hasAttachment; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 주제 - Subject /// <summary> /// 주제 /// </summary> public string Subject { get { return this.subject; } set { SetPropertyValue<string>("Subject", ref this.subject, value); } } #endregion #region 송신 일시 - SendTime /// <summary> /// 송신 일시 /// </summary> public DateTime SendTime { get { return this.sendTime; } set { SetPropertyValue<DateTime>("SendTime", ref this.sendTime, value); } } #endregion #region 첨부 여부 - HasAttachment /// <summary> /// 첨부 여부 /// </summary> public bool HasAttachment { get { return this.hasAttachment; } set { SetPropertyValue<bool>("HasAttachment", ref this.hasAttachment, value); } } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - TestObject() /// <summary> /// 생성자 /// </summary> public TestObject() : base(Session.DefaultSession) { } #endregion #region 생성자 - TestObject(session) /// <summary> /// 생성자 /// </summary> /// <param name="session">세션</param> public TestObject(Session session) : base(session) { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성 후 처리하기 - AfterConstruction() /// <summary> /// 생성 후 처리하기 /// </summary> public override void AfterConstruction() { base.AfterConstruction(); } #endregion } } |