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

728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainForm.cs

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            #region 이벤트를 설정한다.

            Paint += Form_Paint;

            #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 폼 페인트시 처리하기 - Form_Paint(sender, e)

        /// <summary>
        /// 폼 페인트시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            const int MARGIN = 10;
            const int WIDTH  = 150;

            Graphics graphics   = e.Graphics;
            Pen      outlinePen = Pens.Red;
            Brush    fillBrush  = Brushes.LightGreen;

            using(Pen ellipsePen = new Pen(Color.Blue))
            {
                ellipsePen.DashPattern = new float[] { 5, 5 };

                Rectangle rectangle = new Rectangle(MARGIN + 30, 10, WIDTH, WIDTH);

                graphics.DrawEllipse(ellipsePen, rectangle);

                graphics.FillPie(fillBrush, rectangle, 300, 30);

                graphics.DrawPie(outlinePen, rectangle, 300, 30);


                rectangle.X += WIDTH + MARGIN;


                graphics.DrawEllipse(ellipsePen, rectangle);

                graphics.FillPie(fillBrush, rectangle, 300, -330);

                graphics.DrawPie(outlinePen, rectangle, 300, -330);


                rectangle.X =  MARGIN + 30;
                rectangle.Y += WIDTH + MARGIN;


                graphics.DrawEllipse(ellipsePen, rectangle);

                graphics.FillPie(fillBrush, rectangle, 315, 90);

                graphics.DrawPie(outlinePen, rectangle, 315, 90);


                rectangle.X += WIDTH + MARGIN;


                graphics.DrawEllipse(ellipsePen, rectangle);

                graphics.FillPie(fillBrush, rectangle, 315, -270);

                graphics.DrawPie(outlinePen, rectangle, 315, -270);

                rectangle.X =  MARGIN + 30;
                rectangle.Y += WIDTH + MARGIN;

                graphics.DrawEllipse(ellipsePen, rectangle);

                graphics.FillPie(fillBrush, rectangle, 180, 90);

                graphics.DrawPie(outlinePen, rectangle, 180, 90);


                rectangle.X += WIDTH + MARGIN;

                graphics.DrawEllipse(ellipsePen, rectangle);

                graphics.FillPie(fillBrush, rectangle, 180, -270);

                graphics.DrawPie(outlinePen, rectangle, 180, -270);
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker

댓글을 달아 주세요