■ WindowsUIView 클래스에서 커스텀 문서 액션(Document Action)을 추가하는 방법을 보여준다.
▶ DocumentControl1.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 |
using System.Windows.Forms; using DevExpress.XtraBars.Docking2010.Views.WindowsUI; using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 문서 컨트롤 1 /// </summary> public partial class DocumentControl1 : XtraUserControl, ISupportDocumentActions { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - DocumentControl1() /// <summary> /// 생성자 /// </summary> public DocumentControl1() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 문서 액션 질의시 처리하기 - OnQueryDocumentActions(e) /// <summary> /// 문서 액션 질의시 처리하기 /// </summary> /// <param name="e">이벤트 인자</param> public void OnQueryDocumentActions(IDocumentActionsArgs e) { DocumentAction action1 = new DocumentAction(CheckShowActionButton1, ProcessAction1); DocumentAction action2 = new DocumentAction(CheckShowActionButton2, ProcessAction2); action1.Caption = "Action 1"; action2.Caption = "Action 2"; e.DocumentActions.Add(action1); e.DocumentActions.Add(action2); } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Private #region 액션 버튼 표시 여부 체크하기 1 - CheckShowActionButton1(document) /// <summary> /// 액션 버튼 표시 여부 체크하기 1 /// </summary> /// <param name="document">문서</param> /// <returns>액션 버튼 표시 여부</returns> private bool CheckShowActionButton1(Document document) { return true; } #endregion #region 액션 처리하기 1 - ProcessAction1(document) /// <summary> /// 액션 처리하기 1 /// </summary> /// <param name="document">문서</param> private void ProcessAction1(Document document) { MessageBox.Show("Process Action 1"); } #endregion #region 액션 버튼 표시 여부 체크하기 2 - CheckShowActionButton2(document) /// <summary> /// 액션 버튼 표시 여부 체크하기 2 /// </summary> /// <param name="document">문서</param> /// <returns>액션 버튼 표시 여부</returns> private bool CheckShowActionButton2(Document document) { return true; } #endregion #region 액션 처리하기 2 - ProcessAction2(document) /// <summary> /// 액션 처리하기 2 /// </summary> /// <param name="document">문서</param> private void ProcessAction2(Document document) { MessageBox.Show("Process Action 2"); } #endregion } } |
▶ DocumentControl2.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 |
using DevExpress.XtraBars.Docking2010.Views.WindowsUI; using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 문서 컨트롤 2 /// </summary> public partial class DocumentControl2 : XtraUserControl, ISupportDocumentActions { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 체크 여부 1 /// </summary> private bool isChecked1; /// <summary> /// 체크 여부 2 /// </summary> private bool isChecked2; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - DocumentControl2() /// <summary> /// 생성자 /// </summary> public DocumentControl2() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 문서 액션 질의시 처리하기 - OnQueryDocumentActions(e) /// <summary> /// 문서 액션 질의시 처리하기 /// </summary> /// <param name="e">이벤트 인자</param> public void OnQueryDocumentActions(IDocumentActionsArgs e) { DocumentCheckAction action1 = new DocumentCheckAction(() => true, ProcessCheck1, ProcessUncheck1); DocumentCheckAction action2 = new DocumentCheckAction(() => true, ProcessCheck2, ProcessUncheck2); action1.Caption = "Action 1"; action2.Caption = "Action 2"; e.DocumentActions.Add(action1); e.DocumentActions.Add(action2); } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Private #region 체크 처리하기 1 - ProcessCheck1(document) /// <summary> /// 체크 처리하기 1 /// </summary> /// <param name="document">문서</param> private void ProcessCheck1(Document document) { this.isChecked1 = true; } #endregion #region 체크 취소 처리하기 1 - ProcessUncheck1(document) /// <summary> /// 체크 취소 처리하기 1 /// </summary> /// <param name="document">문서</param> private void ProcessUncheck1(Document document) { this.isChecked1 = false; } #endregion #region 체크 처리하기 2 - ProcessCheck2(document) /// <summary> /// 체크 처리하기 2 /// </summary> /// <param name="document">문서</param> private void ProcessCheck2(Document document) { this.isChecked2 = true; } #endregion #region 체크 취소 처리하기 2 - ProcessUncheck2(document) /// <summary> /// 체크 취소 처리하기 2 /// </summary> /// <param name="document">문서</param> private void ProcessUncheck2(Document document) { this.isChecked2 = false; } #endregion } } |
▶ 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 |
using System.Windows.Forms; using DevExpress.Utils; using DevExpress.XtraBars.Docking2010.Views; using DevExpress.XtraBars.Docking2010.Views.WindowsUI; using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; this.pageGroup.Properties.ShowPageHeaders = DefaultBoolean.False; this.windowsUIView.AllowCaptionDragMove = DefaultBoolean.True; this.windowsUIView.QueryControl += windowsUIView_QueryControl; this.windowsUIView.QueryDocumentActions += windowsUIView_QueryDocumentActions; this.windowsUIView.TileClick += windowsUIView_TileClick; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private //////////////////////////////////////////////////////////////////////////////// Event #region 윈도우즈 UI 뷰 컨트롤 질의하기 - windowsUIView_QueryControl(sender, e) /// <summary> /// 윈도우즈 UI 뷰 컨트롤 질의하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void windowsUIView_QueryControl(object sender, QueryControlEventArgs e) { if(e.Document == document1) { e.Control = new DocumentControl1(); } else if(e.Document == document2) { e.Control = new DocumentControl2(); } } #endregion #region 윈도우즈 UI 뷰 문서 액션 질의하기 - windowsUIView_QueryDocumentActions(sender, e) /// <summary> /// 윈도우즈 UI 뷰 문서 액션 질의하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void windowsUIView_QueryDocumentActions(object sender, QueryDocumentActionsEventArgs e) { e.DocumentActions.Add(new DocumentAction(ProcessHello) { Caption = "Hello" }); if(e.Source == pageGroup) { DocumentAction action1 = new DocumentAction((doc) => doc == document2, (doc) => windowsUIView.ActivateDocument(document1)); DocumentAction action2 = new DocumentAction((doc) => doc == document1, (doc) => windowsUIView.ActivateDocument(document2)); action1.Caption = "Document 1"; action2.Caption = "Document 2"; e.DocumentActions.Add(action1); e.DocumentActions.Add(action2); } } #endregion #region 윈도우즈 UI 뷰 타일 클릭시 처리하기 - windowsUIView_TileClick(sender, e) /// <summary> /// 윈도우즈 UI 뷰 타일 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void windowsUIView_TileClick(object sender, TileClickEventArgs e) { if(e.Tile == tile1) { page.Document = document1; } else if(e.Tile == tile2) { page.Document = document2; } } #endregion //////////////////////////////////////////////////////////////////////////////// Function #region HELLO 처리하기 - ProcessHello(document) /// <summary> /// HELLO 처리하기 /// </summary> /// <param name="document">문서</param> private void ProcessHello(Document document) { MessageBox.Show($"{document.Caption} : Hello"); } #endregion } } |