첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

#region 사각형 도형 추가하기 - AddRectangle(canvas, fillBrush, strokeBrush, strokeThickness, left, top, width, height)

/// <summary>
/// 사각형 도형 추가하기
/// </summary>
/// <param name="canvas">캔버스</param>
/// <param name="fillBrush">채우기 브러시</param>
/// <param name="strokeBrush">스트로크 브로시</param>
/// <param name="strokeThickness">스트로크 두께</param>
/// <param name="left">왼쪽</param>
/// <param name="top">위쪽</param>
/// <param name="width">너비</param>
/// <param name="height">높이</param>
/// <returns>사각형 도형</returns>
public Rectangle AddRectangle
(
    Canvas canvas,
    Brush  fillBrush,
    Brush  strokeBrush,
    double strokeThickness,
    double left,
    double top,
    double width,
    double height
)
{
    Rectangle rectangle = new Rectangle();

    Canvas.SetLeft(rectangle, left);
    Canvas.SetTop (rectangle, top );

    rectangle.Width           = width;
    rectangle.Height          = height;
    rectangle.Fill            = fillBrush;
    rectangle.StrokeThickness = strokeThickness;
    rectangle.Stroke          = strokeBrush;

    canvas.Children.Add(rectangle);

    return rectangle;
}

#endregion
#region 사각형 도형 추가하기 - AddRectangle(canvas, fillBrush, strokeBrush, strokeThickness, rectangle)

/// <summary>
/// 사각형 도형 추가하기
/// </summary>
/// <param name="canvas">캔버스</param>
/// <param name="fillBrush">채우기 브러시</param>
/// <param name="strokeBrush">스트로크 브러시</param>
/// <param name="strokeThickness">스트로크 두께</param>
/// <param name="rectangle">사각형</param>
/// <returns>사각형 도형</returns>
public Rectangle AddRectangle(Canvas canvas, Brush fillBrush, Brush strokeBrush, double strokeThickness, Rect rectangle)
{
    return AddRectangle
    (
        canvas,
        fillBrush,
        strokeBrush,
        strokeThickness,
        rectangle.Left,
        rectangle.Top,
        rectangle.Width,
        rectangle.Height
    );
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요