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

728x90
반응형

■ Canvas 클래스 : 타원 도형 추가하기

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

using System.Windows.Controls;

using System.Windows.Media;

using System.Windows.Shapes;

 

#region 타원 도형 추가하기 - AddEllipse(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 Ellipse AddEllipse

(

    Canvas canvas,

    Brush  fillBrush,

    Brush  strokeBrush,

    double strokeThickness,

    double left,

    double top,

    double width,

    double height

)

{

    Ellipse ellipse = new Ellipse();

 

    Canvas.SetLeft(ellipse, left);

    Canvas.SetTop (ellipse, top );

 

    ellipse.Width           = width;

    ellipse.Height          = height;

    ellipse.Fill            = fillBrush;

    ellipse.Stroke          = strokeBrush;

    ellipse.StrokeThickness = strokeThickness;

 

    canvas.Children.Add(ellipse);

 

    return ellipse;

}

 

#endregion

#region 타원 도형 추가하기 - AddEllipse(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 Ellipse AddEllipse(Canvas canvas, Brush fillBrush, Brush strokeBrush, double strokeThickness, Rect rectangle)

{

    return AddEllipse

    (

        canvas,

        fillBrush,

        strokeBrush,

        strokeThickness,

        rectangle.Left,

        rectangle.Top,

        rectangle.Width,

        rectangle.Height

    );

}

 

#endregion

#region 포인트 추가하기 - AddPoint(canvas, fillBrush, strokeBrush, strokeThickness, centerPoint, radius)

 

/// <summary>

/// 포인트 추가하기

/// </summary>

/// <param name="canvas">캔버스</param>

/// <param name="fillBrush">채우기 브러시</param>

/// <param name="strokeBrush">스트로크 브러시</param>

/// <param name="strokeThickness">스트로크 두께</param>

/// <param name="centerPoint">중심 포인트</param>

/// <param name="radius">반경</param>

/// <returns>포인트 타원 도형</returns>

public Ellipse AddPoint

(

    Canvas canvas,

    Brush  fillBrush,

    Brush  strokeBrush,

    double strokeThickness,

    Point  centerPoint,

    double radius

)

{

    return AddEllipse

    (

        canvas,

        fillBrush,

        strokeBrush,

        strokeThickness,

        centerPoint.X - radius,

        centerPoint.Y - radius,

        2 * radius,

        2 * radius

    );

}

 

#endregion

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

728x90
반응형
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요