첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

TestProject.zip
다운로드

▶ MainForm.cs

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

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

        #region Field

        /// <summary>
        /// 커서 배열
        /// </summary>
        private Cursor[] cursorArray;

        /// <summary>
        /// 커서 카운트
        /// </summary>
        private const int CURSOR_COUNT = 18;

        /// <summary>
        /// 현재 커서 인덱스
        /// </summary>
        private int currentCursorIndex = 0;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

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

            #region 이벤트를 설정한다.

            Load            += Form_Load;
            this.timer.Tick += timer_Tick;

            #endregion
        }

        #endregion

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

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            const int CURSOR_WIDTH  = 32;
            const int CURSOR_HEIGHT = 32;

            float centetX = CURSOR_WIDTH  / 2f;
            float centerY = CURSOR_HEIGHT / 2f;

            float radiusX = centetX * 0.9f;
            float radiusY = centetX * 0.4f;

            RectangleF rectangle = new RectangleF(-radiusX, -radiusY, 2 * radiusX, 2 * radiusY);

            float radius = centetX * 0.15f;

            Matrix transform1 = new Matrix();

            transform1.Rotate(60f, MatrixOrder.Append);

            transform1.Translate(centetX, centerY, MatrixOrder.Append);

            Matrix transform2 = new Matrix();

            transform2.Rotate(-60f, MatrixOrder.Append);

            transform2.Translate(centetX, centerY, MatrixOrder.Append);

            Matrix transform3 = new Matrix();

            transform3.Translate(centetX, centerY, MatrixOrder.Append);

            Bitmap sourceBitmap = new Bitmap(CURSOR_WIDTH, CURSOR_HEIGHT);

            using(Graphics sourceGraphics = Graphics.FromImage(sourceBitmap))
            {
                sourceGraphics.SmoothingMode = SmoothingMode.AntiAlias;

                sourceGraphics.Clear(Color.Transparent);

                sourceGraphics.Transform = transform1;

                sourceGraphics.DrawEllipse(Pens.Red, rectangle);

                sourceGraphics.Transform = transform2;

                sourceGraphics.DrawEllipse(Pens.Red, rectangle);

                sourceGraphics.Transform = transform3;

                sourceGraphics.DrawEllipse(Pens.Red, rectangle);

                sourceGraphics.FillEllipse(Brushes.Black, -radius, -radius, 2 * radius, 2 * radius);
            }

            this.cursorArray = new Cursor[CURSOR_COUNT];

            double theta1  = 0;
            double dtheta1 = 2 * Math.PI / CURSOR_COUNT;
            double theta2  = 0;
            double dtheta2 = 2 * Math.PI / CURSOR_COUNT * 2;
            double theta3  = 0;
            double dtheta3 = 2 * Math.PI / CURSOR_COUNT * 3;

            for(int i = 0; i < CURSOR_COUNT; i++)
            {
                Bitmap cursorBitmap = new Bitmap(CURSOR_WIDTH, CURSOR_HEIGHT);

                using(Graphics cursorGraphics = Graphics.FromImage(cursorBitmap))
                {
                    cursorGraphics.SmoothingMode = SmoothingMode.AntiAlias;

                    cursorGraphics.DrawImage(sourceBitmap, 0, 0);

                    cursorGraphics.Transform = transform1;

                    double x1 = radiusX * Math.Cos(theta1);
                    double y1 = radiusY * Math.Sin(theta1);

                    cursorGraphics.FillEllipse(Brushes.Red, (int)(x1 - radius), (int)(y1 - radius), 2 * radius, 2 * radius);

                    theta1 += dtheta1;

                    cursorGraphics.Transform = transform2;

                    double x2 = radiusX * Math.Cos(theta2);
                    double y2 = radiusY * Math.Sin(theta2);

                    cursorGraphics.FillEllipse(Brushes.Green, (int)(x2 - radius), (int)(y2 - radius), 2 * radius, 2 * radius);

                    theta2 += dtheta2;

                    cursorGraphics.Transform = transform3;

                    double x3 = radiusX * Math.Cos(theta3);
                    double y3 = radiusY * Math.Sin(theta3);

                    cursorGraphics.FillEllipse(Brushes.Blue, (int)(x3 - radius), (int)(y3 - radius), 2 * radius, 2 * radius);

                    theta3 += dtheta3;
                }

                this.cursorArray[i] = new Cursor(cursorBitmap.GetHicon());

                theta1 += dtheta1;
            }
        }

        #endregion
        #region 타이머 틱 처리하기 - timer_Tick(sender, e)

        /// <summary>
        /// 타이머 틱 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void timer_Tick(object sender, EventArgs e)
        {
            this.currentCursorIndex = (this.currentCursorIndex + 1) % CURSOR_COUNT;

            Cursor = this.cursorArray[this.currentCursorIndex];
        }

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