■ UltraGrid 클래스에서 포커스 사각형을 커스텀 정의하는 방법을 보여준다.
▶ UltraGrid 클래스 : 포커스 사각형 커스텀 정의하기 예제 (C#)
1 2 3 4 5 6 7 8 9 |
using Infragistics.Win.UltraWinGrid; private UltraGrid ultraGrid; ... this.ultraGrid.DrawFilter = new CustomUIElementDrawFilter(new Pen(Brushes.Red, 1f), 1, 1, -3, -3); |
▶ UltraGrid 클래스 : 포커스 사각형 커스텀 정의하기 (C#)
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 |
using System.Drawing; using Infragistics.Win; /// <summary> /// 커스텀 UI 엘리먼트 그리기 필터 /// </summary> public class CustomUIElementDrawFilter : IUIElementDrawFilter { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 포커스 펜 /// </summary> private Pen focusPen = null; /// <summary> /// 오프셋 X /// </summary> private int offsetX = 0; /// <summary> /// 오프셋 Y /// </summary> private int offsetY = 0; /// <summary> /// 오프셋 너비 /// </summary> private int offsetWidth = 0; /// <summary> /// 오프셋 높이 /// </summary> private int offsetHeight = 0; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomUIElementDrawFilter(focusPen, offsetX, offsetY, offsetWidth, offsetHeight) /// <summary> /// 생성자 /// </summary> /// <param name="focusPen">포커스 펜</param> /// <param name="offsetX">오프셋 X</param> /// <param name="offsetY">오프셋 Y</param> /// <param name="offsetWidth">오프셋 너비</param> /// <param name="offsetHeight">오프셋 높이</param> public CustomUIElementDrawFilter(Pen focusPen, int offsetX, int offsetY, int offsetWidth, int offsetHeight) { this.focusPen = focusPen; this.offsetX = offsetX; this.offsetY = offsetY; this.offsetWidth = offsetWidth; this.offsetHeight = offsetHeight; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 엘리먼트 그리기 - DrawElement(drawPhase, drawParameter) /// <summary> /// 엘리먼트 그리기 /// </summary> /// <param name="drawPhase">그리기 단계</param> /// <param name="drawParameter">그리기 파라미터</param> /// <returns>처리 결과</returns> public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParameter) { bool result = false; if(drawPhase == DrawPhase.BeforeDrawFocus) { Rectangle regularRectangle = drawParameter.Element.Rect; Rectangle clippedRectangle = drawParameter.Element.ClipRect; Rectangle focusRectangle; if((clippedRectangle.Width < regularRectangle.Width) || (clippedRectangle.Height < regularRectangle.Height)) { focusRectangle = clippedRectangle; } else { focusRectangle = regularRectangle; } focusRectangle = new Rectangle ( focusRectangle.X + this.offsetX , focusRectangle.Y + this.offsetY , focusRectangle.Width + this.offsetWidth, focusRectangle.Height + this.offsetHeight ); drawParameter.Graphics.DrawRectangle(this.focusPen, focusRectangle); result = true; } return result; } #endregion #region 필터를 위해 단계 구하기 - GetPhasesToFilter(drawParameter) /// <summary> /// 필터를 위해 단계 구하기 /// </summary> /// <param name="drawParameter">그리기 파라미터</param> /// <returns>그리기 파라미터</returns> public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParameter) { return DrawPhase.BeforeDrawFocus; } #endregion } |