첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

▶ UltraGrid 클래스 : 포커스 사각형 사용자 정의하기 예제

using Infragistics.Win.UltraWinGrid;

private UltraGrid ultraGrid;

...

this.ultraGrid.DrawFilter = new CustomUIElementDrawFilter(new Pen(Brushes.Red, 1f), 1, 1, -3, -3);

 

728x90

 

▶ UltraGrid 클래스 : 포커스 사각형 사용자 정의하기

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
}
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker

댓글을 달아 주세요