■ 버튼 배경 그리기

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

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

댓글을 달아 주세요