첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ 버튼 배경 그리기

----------------------------------------------------------------------------------------------------

using System.Drawing;

 

Graphics graphics;

 

...

 

DrawButtonBackground

(

    graphics,

    new Rectangle(100, 100, 300, 50),

    Color.FromArgb(253, 253, 253),

    Color.FromArgb(200, 210, 232),

    Color.SteelBlue

);

----------------------------------------------------------------------------------------------------

 

■ 버튼 배경 그리기

----------------------------------------------------------------------------------------------------

using System.Drawing;

using System.Drawing.Drawing2D;

 

#region 버튼 배경 그리기 - DrawButtonBackground(graphics, targetRectangle, startColor, endColor, borderColor)

 

/// <summary>

/// 버튼 배경 그리기

/// </summary>

/// <param name="graphics">그래픽스</param>

/// <param name="targetRectangle">타겟 사각형</param>

/// <param name="startColor">시작 색상</param>

/// <param name="endColor">종료 색상</param>

/// <param name="borderColor">경계선 색상</param>

public void DrawButtonBackground(Graphics graphics, Rectangle targetRectangle, Color startColor, Color endColor,

    Color borderColor)

{

    LinearGradientBrush brush = new LinearGradientBrush

    (

        new Point(0, 0),

        new Point(0, targetRectangle.Height),

        startColor,

        endColor

    );

 

    Pen pen = new Pen(borderColor, 1f);

 

    graphics.FillRectangle(brush, targetRectangle);

 

    graphics.DrawRectangle

    (

        pen,

        targetRectangle.Left,

        targetRectangle.Top,

        targetRectangle.Width - 1,

        targetRectangle.Height - 1

    );

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요