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

728x90
반응형
728x170

TestSolution.zip
0.02MB

[TestLibrary 프로젝트]

▶ CircularWaitControlStyle.cs

namespace TestLibrary
{
    /// <summary>
    /// 환형 대기 컨트롤 스타일
    /// </summary>
    public enum CircularWaitControlStyle
    {
        /// <summary>
        /// MCS OSX
        /// </summary>
        MACOSX,

        /// <summary>
        /// 파이어폭스
        /// </summary>
        FIREFOX,

        /// <summary>
        /// IE7
        /// </summary>
        IE7,

        /// <summary>
        /// 커스텀
        /// </summary>
        CUSTOM
    }
}

 

728x90

 

▶ CircularWaitControl.cs

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

namespace TestLibrary
{
    /// <summary>
    /// 환형 대기 컨트롤
    /// </summary>
    public partial class CircularWaitControl : Control
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 원 각도 카운트
        /// </summary>
        private const double CIRCLE_DEGREE_COUNT = 360;

        /// <summary>
        /// 반원 각도 카운트
        /// </summary>
        private const double HALF_CIRCLE_DEGREE_COUNT = CIRCLE_DEGREE_COUNT / 2;

        /// <summary>
        /// 디폴트 외부 원 반경
        /// </summary>
        private const int DEFAULT_OUTER_CIRCLE_RADIUS = 10;

        /// <summary>
        /// 디폴트 내부 원 반경
        /// </summary>
        private const int DEFAULT_INNER_CIRCLE_RADIUS = 8;

        /// <summary>
        /// 디폴트 바퀴살 카운트
        /// </summary>
        private const int DEFAULT_SPOKE_COUNT = 10;

        /// <summary>
        /// 디폴트 바퀴살 두께
        /// </summary>
        private const int DEFAULT_SPOKE_THICKNESS = 4;

        /// <summary>
        /// 디폴트 색상
        /// </summary>
        private readonly Color defaultColor = Color.DarkGray;

        /// <summary>
        /// MAC OSX 내부 원 반경
        /// </summary>
        private const int MAC_OSX_INNER_CIRCLE_RADIUS = 5;

        /// <summary>
        /// MAC OSX 외부 원 반경
        /// </summary>
        private const int MAC_OSX_OUTER_CIRCLE_RADIUS = 11;

        /// <summary>
        /// MAC OSX 바퀴살 카운트
        /// </summary>
        private const int MAC_OSX_SPOKE_COUNT = 12;

        /// <summary>
        /// MAC OSX 바퀴살 두께
        /// </summary>
        private const int MAC_OSX_SPOKE_THICKNESS = 2;

        /// <summary>
        /// 파이어폭스 내부 원 반경
        /// </summary>
        private const int FIREFOX_INNER_CIRCLE_RADIUS = 6;

        /// <summary>
        /// 파이어폭스 외부 원 반경
        /// </summary>
        private const int FIREFOX_OUTER_CIRCLE_RADIUS = 7;

        /// <summary>
        /// 파이어폭스 바퀴살 카운트
        /// </summary>
        private const int FIREFOX_SPOKE_COUNT = 9;

        /// <summary>
        /// 파이어폭스 바퀴살 두께
        /// </summary>
        private const int FIREFOX_SPOKE_THICKNESS = 4;

        /// <summary>
        /// IE7 내부 원 반경
        /// </summary>
        private const int IE7_INNER_CIRCLE_RADIUS = 8;

        /// <summary>
        /// IE7 외부 원 반경
        /// </summary>
        private const int IE7_OUTER_CIRCLE_RADIUS = 9;

        /// <summary>
        /// IE7 바퀴살 카운트
        /// </summary>
        private const int IE7_SPOKE_COUNT = 24;

        /// <summary>
        /// IE7 바퀴살 두께
        /// </summary>
        private const int IE7_SPOKE_THICKNESS = 4;

        /// <summary>
        /// 타이머
        /// </summary>
        private Timer timer;

        /// <summary>
        /// 타이머 활성 여부
        /// </summary>
        private bool isTimerActive;

        /// <summary>
        /// 바퀴살 카운트
        /// </summary>
        private int spokeCount;

        /// <summary>
        /// 바퀴살 두께
        /// </summary>
        private int spokeThickness;

        /// <summary>
        /// 진행 값
        /// </summary>
        private int progressValue;

        /// <summary>
        /// 내부 원 반경
        /// </summary>
        private int innerCircleRadius;

        /// <summary>
        /// 외부 원 반경
        /// </summary>
        private int outerCircleRadius;

        /// <summary>
        /// 중심 포인트
        /// </summary>
        private PointF centerPoint;

        /// <summary>
        /// 바퀴살 색상
        /// </summary>
        private Color spokeColor;

        /// <summary>
        /// 색상 배열
        /// </summary>
        private Color[] colorArray;

        /// <summary>
        /// 각도 배열
        /// </summary>
        private double[] angleArray;

        /// <summary>
        /// 환형 대기 컨트롤 스타일
        /// </summary>
        private CircularWaitControlStyle circularWaitControlStyle;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 환형 대기 컨트롤 스타일 - CircularWaitControlStyle

        /// <summary>
        /// 환형 대기 컨트롤 스타일
        /// </summary>
        [Category("CircularWaitControl")]
        [DefaultValue(typeof(CircularWaitControlStyle), "CUSTOM")]
        [Description("로딩 원 스타일을 구하거나 설정한다.")]
        public CircularWaitControlStyle CircularWaitControlStyle
        {
            get
            {
                return this.circularWaitControlStyle;
            }
            set
            {
                this.circularWaitControlStyle = value;

                switch(this.circularWaitControlStyle)
                {
                    case CircularWaitControlStyle.MACOSX :

                        SetCircleAppearance
                        (
                            MAC_OSX_SPOKE_COUNT, 
                            MAC_OSX_SPOKE_THICKNESS,
                            MAC_OSX_INNER_CIRCLE_RADIUS, 
                            MAC_OSX_OUTER_CIRCLE_RADIUS
                        );

                        break;

                    case CircularWaitControlStyle.FIREFOX :

                        SetCircleAppearance
                        (
                            FIREFOX_SPOKE_COUNT,
                            FIREFOX_SPOKE_THICKNESS,
                            FIREFOX_INNER_CIRCLE_RADIUS,
                            FIREFOX_OUTER_CIRCLE_RADIUS
                        );

                        break;

                    case CircularWaitControlStyle.IE7 :

                        SetCircleAppearance
                        (
                            IE7_SPOKE_COUNT,
                            IE7_SPOKE_THICKNESS,
                            IE7_INNER_CIRCLE_RADIUS,
                            IE7_OUTER_CIRCLE_RADIUS
                        );

                        break;

                    case CircularWaitControlStyle.CUSTOM :

                        SetCircleAppearance
                        (
                            DEFAULT_SPOKE_COUNT, 
                            DEFAULT_SPOKE_THICKNESS, 
                            DEFAULT_INNER_CIRCLE_RADIUS, 
                            DEFAULT_OUTER_CIRCLE_RADIUS
                        );

                        break;
                }
            }
        }

        #endregion
        #region 외부 원 반경 - OuterCircleRadius

        /// <summary>
        /// 외부 원 반경
        /// </summary>
        [Category("CircularWaitControl")]
        [Description("외부 원 반경을 구하거나 설정한다.")]
        public int OuterCircleRadius
        {
            get
            {
                if(this.outerCircleRadius == 0)
                {
                    this.outerCircleRadius = DEFAULT_OUTER_CIRCLE_RADIUS;
                }

                return this.outerCircleRadius;
            }
            set
            {
                this.outerCircleRadius = value;

                Invalidate();
            }
        }

        #endregion
        #region 내부 원 반경 - InnerCircleRadius

        /// <summary>
        /// 내부 원 반경
        /// </summary>
        [Category("CircularWaitControl")]
        [Description("내부 원 반경을 구하거나 설정한다.")]
        public int InnerCircleRadius
        {
            get
            {
                if(this.innerCircleRadius == 0)
                {
                    this.innerCircleRadius = DEFAULT_INNER_CIRCLE_RADIUS;
                }

                return this.innerCircleRadius;
            }
            set
            {
                this.innerCircleRadius = value;

                Invalidate();
            }
        }

        #endregion
        #region 바퀴살 카운트 - SpokeCount

        /// <summary>
        /// 바퀴살 카운트
        /// </summary>
        [Category("CircularWaitControl")]
        [Description("바퀴살 카운트를 구하거나 설정한다.")]
        public int SpokeCount
        {
            get
            {
                if(this.spokeCount == 0)
                {
                    this.spokeCount = DEFAULT_SPOKE_COUNT;
                }

                return this.spokeCount;
            }
            set
            {
                if(this.spokeCount != value && this.spokeCount > 0)
                {
                    this.spokeCount = value;

                    SetColorArray();

                    SetSpokeAngleArray();

                    Invalidate();
                }
            }
        }

        #endregion
        #region 바퀴살 두께 - SpokeThickness

        /// <summary>
        /// 바퀴살 두께
        /// </summary>
        [Category("CircularWaitControl")]
        [Description("바퀴살 두께를 구하거나 설정한다.")]
        public int SpokeThickness
        {
            get
            {
                if(this.spokeThickness <= 0)
                {
                    this.spokeThickness = DEFAULT_SPOKE_THICKNESS;
                }

                return this.spokeThickness;
            }
            set
            {
                this.spokeThickness = value;

                Invalidate();
            }
        }

        #endregion
        #region 바퀴살 색상 - SpokeColor

        /// <summary>
        /// 바퀴살 색상
        /// </summary>
        [TypeConverter("System.Drawing.ColorConverter")]
        [Category("CircularWaitControl")]
        [Description("바퀴살 색상을 구하거나 설정한다.")]
        public Color SpokeColor
        {
            get
            {
                return this.spokeColor;
            }
            set
            {
                this.spokeColor = value;

                SetColorArray();

                Invalidate();
            }
        }

        #endregion
        #region 활성 여부 - Active

        /// <summary>
        /// 활성 여부
        /// </summary>
        [Category("CircularWaitControl")]
        public bool Active
        {
            get
            {
                return this.isTimerActive;
            }
            set
            {
                this.isTimerActive = value;

                ActivateTimer();
            }
        }

        #endregion
        #region 회전 속도 - RotationSpeed

        /// <summary>
        /// 회전 속도
        /// </summary>
        [Category("CircularWaitControl")]
        [Description("회전 속도를 구하거나 설정한다.")]
        public int RotationSpeed
        {
            get
            {
                return this.timer.Interval;
            }
            set
            {
                if(value > 0)
                {
                    this.timer.Interval = value;
                }
            }
        }

        #endregion

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

        #region 생성자 - CircularWaitControl()

        /// <summary>
        /// 생성자
        /// </summary>
        public CircularWaitControl()
        {
            SetStyle(ControlStyles.UserPaint                   , true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer       , true);
            SetStyle(ControlStyles.ResizeRedraw                , true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            this.spokeColor = this.defaultColor;

            SetColorArray();

            SetSpokeAngleArray();

            SetControlCenterPoint();

            this.timer = new Timer();

            this.timer.Tick += timer_Tick;

            ActivateTimer();

            Resize += Control_Resize;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 선호 크기 구하기 - GetPreferredSize(proposedSize)

        /// <summary>
        /// 선호 크기 구하기
        /// </summary>
        /// <param name="proposedSize">제안 크기</param>
        /// <returns>선호 크기</returns>
        public override Size GetPreferredSize(Size proposedSize)
        {
            proposedSize.Width = (this.outerCircleRadius + this.spokeThickness) * 2;

            return proposedSize;
        }

        #endregion
        #region 원 모양 설정하기 - SetCircleAppearance(spokeCount, spokeThickness, innerCircleRadius, outerCircleRadius)

        /// <summary>
        /// 원 모양 설정하기
        /// </summary>
        /// <param name="spokeCount">바퀴살 카운트</param>
        /// <param name="spokeThickness">바퀴살 두께</param>
        /// <param name="innerCircleRadius">내부 원 반경</param>
        /// <param name="outerCircleRadius">외부 원 반경</param>
        public void SetCircleAppearance(int spokeCount, int spokeThickness, int innerCircleRadius, int outerCircleRadius)
        {
            SpokeCount        = spokeCount;
            SpokeThickness    = spokeThickness;
            InnerCircleRadius = innerCircleRadius;
            OuterCircleRadius = outerCircleRadius;

            Invalidate();
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 페인트시 처리하기 - OnPaint(e)

        /// <summary>
        /// 페인트시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if(this.spokeCount > 0)
            {
                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

                int progress = this.progressValue;

                for(int i = 0; i < this.spokeCount; i++)
                {
                    progress = progress % this.spokeCount;

                    DrawLine
                    (
                        e.Graphics,
                        GetCoordinate(this.centerPoint, this.innerCircleRadius, this.angleArray[progress]),
                        GetCoordinate(this.centerPoint, this.outerCircleRadius, this.angleArray[progress]),
                        this.colorArray[i],
                        this.spokeThickness
                    );

                    progress++;
                }
            }

            base.OnPaint(e);
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 컨트롤 크기 변경시 처리하기 - Control_Resize(sender, e)

        /// <summary>
        /// 컨트롤 크기 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Control_Resize(object sender, EventArgs e)
        {
            SetControlCenterPoint();
        }

        #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.progressValue = ++this.progressValue % this.spokeCount;

            Invalidate();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 어두운 색상 구하기 - GetDarkColor(color, percentage)

        /// <summary>
        /// 어두운 색상 구하기
        /// </summary>
        /// <param name="color">색상</param>
        /// <param name="percentage">비율</param>
        /// <returns>어두운 색상</returns>
        private Color GetDarkColor(Color color, int percentage)
        {
            int red   = color.R;
            int green = color.G;
            int blue  = color.B;

            return Color.FromArgb
            (
                percentage,
                Math.Min(red  , byte.MaxValue),
                Math.Min(green, byte.MaxValue),
                Math.Min(blue , byte.MaxValue)
            );
        }

        #endregion
        #region 색상 배열 구하기 - GetColorArray(color, isColorShadeded, spokeCount)

        /// <summary>
        /// 색상 배열 구하기
        /// </summary>
        /// <param name="color">색상</param>
        /// <param name="isColorShadeded">색상 음영 여부</param>
        /// <param name="spokeCount">바퀴살 카운트</param>
        /// <returns>색상 배열</returns>
        private Color[] GetColorArray(Color color, bool isColorShadeded, int spokeCount)
        {
            Color[] colorArray = new Color[SpokeCount];

            byte increment = (byte)(byte.MaxValue / SpokeCount);

            byte darkness = 0;

            for(int i = 0; i < SpokeCount; i++)
            {
                if(isColorShadeded)
                {
                    if(i == 0 || i < SpokeCount - spokeCount)
                    {
                        colorArray[i] = color;
                    }
                    else
                    {
                        darkness += increment;

                        if(darkness > byte.MaxValue)
                        {
                            darkness = byte.MaxValue;
                        }

                        colorArray[i] = GetDarkColor(color, darkness);
                    }
                }
                else
                {
                    colorArray[i] = color;
                }
            }

            return colorArray;
        }

        #endregion
        #region 색상 배열 설정하기 - SetColorArray()

        /// <summary>
        /// 색상 배열 설정하기
        /// </summary>
        private void SetColorArray()
        {
            this.colorArray = GetColorArray(this.spokeColor, Active, this.spokeCount);
        }

        #endregion
        #region 바퀴살 각도 배열 구하기 - GetSpokeAngleArray(spokeCount)

        /// <summary>
        /// 바퀴살 각도 배열 구하기
        /// </summary>
        /// <param name="spokeCount">바퀴살 카운트</param>
        /// <returns>바퀴살 각도 배열</returns>
        private double[] GetSpokeAngleArray(int spokeCount)
        {
            double[] angleArray = new double[spokeCount];

            double angle = (double) CIRCLE_DEGREE_COUNT / spokeCount;

            for(int i = 0; i < spokeCount; i++)
            {
                angleArray[i] = (i == 0 ? angle : angleArray[i - 1] + angle);
            }

            return angleArray;
        }

        #endregion
        #region 바퀴살 각도 배열 설정하기 - SetSpokeAngleArray()

        /// <summary>
        /// 바퀴살 각도 배열 설정하기
        /// </summary>
        private void SetSpokeAngleArray()
        {
            this.angleArray = GetSpokeAngleArray(SpokeCount);
        }

        #endregion
        #region 컨트롤 중심 포인트 구하기 - GetControlCenterPoint(control)

        /// <summary>
        /// 컨트롤 중심 포인트 구하기
        /// </summary>
        /// <param name="control">컨트롤</param>
        /// <returns>컨트롤 중심 포인트</returns>
        private PointF GetControlCenterPoint(Control control)
        {
            return new PointF(control.Width / 2, control.Height / 2 - 1);
        }

        #endregion
        #region 컨트롤 중심 포인트 설정하기 - SetControlCenterPoint()

        /// <summary>
        /// 컨트롤 중심 포인트 설정하기
        /// </summary>
        private void SetControlCenterPoint()
        {
            this.centerPoint = GetControlCenterPoint(this);
        }

        #endregion
        #region 타이머 활성화시키기 - ActivateTimer()

        /// <summary>
        /// 타이머 활성화시키기
        /// </summary>
        private void ActivateTimer()
        {
            if(this.isTimerActive)
            {
                this.timer.Start();
            }
            else
            {
                this.timer.Stop();

                this.progressValue = 0;
            }

            SetColorArray();

            Invalidate();
        }

        #endregion
        #region 좌표 구하기 - GetCoordinate(centerPoint, radius, angle)

        /// <summary>
        /// 좌표 구하기
        /// </summary>
        /// <param name="centerPoint">중심 포인트</param>
        /// <param name="radius">반경</param>
        /// <param name="angle">각도</param>
        /// <returns>좌표</returns>
        private PointF GetCoordinate(PointF centerPoint, int radius, double angle)
        {
            double radian = Math.PI * angle / HALF_CIRCLE_DEGREE_COUNT;

            return new PointF
            (
                centerPoint.X + radius * (float)Math.Cos(radian),
                centerPoint.Y + radius * (float)Math.Sin(radian)
            );
        }

        #endregion
        #region 선 그리기 - DrawLine(graphics, startPoint, endPoint, color, thickness)

        /// <summary>
        /// 선 그리기
        /// </summary>
        /// <param name="graphics">그래픽스</param>
        /// <param name="startPoint">시작 포인트</param>
        /// <param name="endPoint">종료 포인트</param>
        /// <param name="color">색상</param>
        /// <param name="thickness">두께</param>
        private void DrawLine(Graphics graphics, PointF startPoint, PointF endPoint, Color color, int thickness)
        {
            using(Pen pen = new Pen(new SolidBrush(color), thickness))
            {
                pen.StartCap = LineCap.Round;
                pen.EndCap   = LineCap.Round;

                graphics.DrawLine(pen, startPoint, endPoint);
            }
        }

        #endregion
    }
}

 

300x250

 

▶ CircularWaitControlToolStripMenuItem.cs

using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace TestLibrary
{
    /// <summary>
    /// 환형 대기 컨트롤 도구 스트립 메뉴 항목
    /// </summary>
    [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)]
    public class CircularWaitControlToolStripMenuItem : ToolStripControlHost
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 환형 대기 컨트롤 - CircularWaitControl

        /// <summary>
        /// 환형 대기 컨트롤
        /// </summary>
        [RefreshProperties(RefreshProperties.All)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public CircularWaitControl CircularWaitControl
        {
            get
            {
                return Control as CircularWaitControl;
            }
        }

        #endregion

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

        #region 생성자 - CircularWaitControlToolStripMenuItem()

        /// <summary>
        /// 생성자
        /// </summary>
        public CircularWaitControlToolStripMenuItem() : base(new CircularWaitControl())
        {
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 선호 크기 구하기 - GetPreferredSize(proposedSize)

        /// <summary>
        /// 선호 크기 구하기
        /// </summary>
        /// <param name="proposedSize">제안 크기</param>
        /// <returns>선호 크기</returns>
        public override Size GetPreferredSize(Size proposedSize)
        {
            return CircularWaitControl.GetPreferredSize(proposedSize);
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 컨트롤 이벤트 구독시 처리하기 - OnSubscribeControlEvents(control)

        /// <summary>
        /// 컨트롤 이벤트 구독시 처리하기
        /// </summary>
        /// <param name="control">컨트롤</param>
        protected override void OnSubscribeControlEvents(Control control)
        {
            base.OnSubscribeControlEvents(control);
        }

        #endregion
        #region 컨트롤 이벤트 구독 취소시 처리하기 - OnUnsubscribeControlEvents(control)

        /// <summary>
        /// 컨트롤 이벤트 구독 취소시 처리하기
        /// </summary>
        /// <param name="control">컨트롤</param>
        protected override void OnUnsubscribeControlEvents(Control control)
        {
            base.OnUnsubscribeControlEvents(control);
        }

        #endregion
    }
}

 

[TestProject 프로젝트]

▶ MainForm.cs

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

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

        #region 생성자 - MainForm()

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

            Load                                             += Form_Load;
            this.activateButton.Click                        += activateButton_Click;
            this.deactivateButton.Click                      += deactivateButton_Click;
            this.spokeCountNumericUpDown.ValueChanged        += spokeCountNumericUpDown_ValueChanged;
            this.spokeThicknessNumericUpDown.ValueChanged    += spokeThicknessNumericUpDown_ValueChanged;
            this.innerCircleRadiusNumericUpDown.ValueChanged += innerCircleRadiusNumericUpDown_ValueChanged;
            this.outerCircleRadiusNumericUpDown.ValueChanged += outerCircleRadiusNumericUpDown_ValueChanged;
            this.rotationSpeedNumericUpDown.ValueChanged     += rotationSpeedNumericUpDown_ValueChanged;
            this.colorComboBox.SelectedIndexChanged          += colorComboBox_SelectedIndexChanged;
            this.macOSXStyleButton.Click                     += macOSXStyleButton_Click;
            this.fireFoxStyleButton.Click                    += fireFoxStyleButton_Click;
            this.ie7StyleButton.Click                        += ie7StyleButton_Click;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

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

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            foreach(string color in Enum.GetNames(typeof(KnownColor)))
            {
                this.colorComboBox.Items.Add(color);
            }

            this.spokeCountNumericUpDown.Value        = this.customStyleCircularWaitControl.SpokeCount;
            this.spokeThicknessNumericUpDown.Value    = this.customStyleCircularWaitControl.SpokeThickness;
            this.innerCircleRadiusNumericUpDown.Value = this.customStyleCircularWaitControl.InnerCircleRadius;
            this.outerCircleRadiusNumericUpDown.Value = this.customStyleCircularWaitControl.OuterCircleRadius;
            this.rotationSpeedNumericUpDown.Value     = this.customStyleCircularWaitControl.RotationSpeed;
            this.colorComboBox.SelectedIndex          = this.colorComboBox.FindString
            (
                this.customStyleCircularWaitControl.SpokeColor.ToKnownColor().ToString()
            );
        }

        #endregion

        #region 활성화하기 버튼 클릭시 처리하기 - activateButton_Click(sender, e)

        /// <summary>
        /// 활성화하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void activateButton_Click(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.Active  = true;
            this.firefoxStyleCircularWaitControl.Active = true;
            this.ie7StyleCircularWaitControl.Active     = true;
            this.macOSXStyleCircularWaitControl.Active  = true;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.Active = true;
        }

        #endregion
        #region 비활성하기 버튼 클릭시 처리하기 - deactivateButton_Click(sender, e)

        /// <summary>
        /// 비활성하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void deactivateButton_Click(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.Active  = false;
            this.firefoxStyleCircularWaitControl.Active = false;
            this.ie7StyleCircularWaitControl.Active     = false;
            this.macOSXStyleCircularWaitControl.Active  = false;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.Active = false;
        }

        #endregion
        #region 바퀴살 카운트 숫자 UP/DOWN 값 변경시 처리하기 - spokeCountNumericUpDown_ValueChanged(sender, e)

        /// <summary>
        /// 바퀴살 카운트 숫자 UP/DOWN 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void spokeCountNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.SpokeCount = (short)this.spokeCountNumericUpDown.Value;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.SpokeCount = (short)this.spokeCountNumericUpDown.Value;
        }

        #endregion
        #region 바퀴살 두께 숫자 UP/DOWN 값 변경시 처리하기 - spokeThicknessNumericUpDown_ValueChanged(sender, e)

        /// <summary>
        /// 바퀴살 두께 숫자 UP/DOWN 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void spokeThicknessNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.SpokeThickness = (int)this.spokeThicknessNumericUpDown.Value;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.SpokeThickness = (int)this.spokeThicknessNumericUpDown.Value;
        }

        #endregion
        #region 내부 원 반경 숫자 UP/DOWN 값 변경시 처리하기 - innerCircleRadiusNumericUpDown_ValueChanged(sender, e)

        /// <summary>
        /// 내부 원 반경 숫자 UP/DOWN 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void innerCircleRadiusNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.InnerCircleRadius = (int)this.innerCircleRadiusNumericUpDown.Value;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.InnerCircleRadius = (int)this.innerCircleRadiusNumericUpDown.Value;
        }

        #endregion
        #region 외부 원 반경 숫자 UP/DOWN 값 변경시 처리하기 - outerCircleRadiusNumericUpDown_ValueChanged(sender, e)

        /// <summary>
        /// 외부 원 반경 숫자 UP/DOWN 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void outerCircleRadiusNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.OuterCircleRadius = (int)this.outerCircleRadiusNumericUpDown.Value;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.OuterCircleRadius = (int)this.outerCircleRadiusNumericUpDown.Value;
        }

        #endregion
        #region 회전 속도 숫자 UP/DOWN 값 변경시 처리하기 - rotationSpeedNumericUpDown_ValueChanged(sender, e)

        /// <summary>
        /// 회전 속도 숫자 UP/DOWN 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void rotationSpeedNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.RotationSpeed = (int)this.rotationSpeedNumericUpDown.Value;

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.RotationSpeed = (int)this.rotationSpeedNumericUpDown.Value;
        }

        #endregion
        #region 색상 콤보 박스 선택 인덱스 변경시 처리하기 - colorComboBox_SelectedIndexChanged(sender, e)

        /// <summary>
        /// 색상 콤보 박스 선택 인덱스 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void colorComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.customStyleCircularWaitControl.SpokeColor = Color.FromKnownColor
            (
                (KnownColor)Enum.Parse
                (
                    typeof(KnownColor),
                    this.colorComboBox.SelectedItem.ToString()
                )
            );

            this.circularWaitControlToolStripMenuItem.CircularWaitControl.SpokeColor = Color.FromKnownColor
            (
                (KnownColor)Enum.Parse
                (
                    typeof(KnownColor),
                    this.colorComboBox.SelectedItem.ToString()
                )
            );
        }

        #endregion

        #region MAC OSX 스타일 버튼 클릭시 처리하기 - macOSXStyleButton_Click(sender, e)

        /// <summary>
        /// MAC OSX 스타일 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void macOSXStyleButton_Click(object sender, EventArgs e)
        {
            this.spokeCountNumericUpDown.Value        = 12;
            this.spokeThicknessNumericUpDown.Value    = 2;
            this.innerCircleRadiusNumericUpDown.Value = 5;
            this.outerCircleRadiusNumericUpDown.Value = 11;
            this.rotationSpeedNumericUpDown.Value     = 80;
        }

        #endregion
        #region 파이어폭스 스타일 버튼 클릭시 처리하기 - fireFoxStyleButton_Click(sender, e)

        /// <summary>
        /// 파이어폭스 스타일 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void fireFoxStyleButton_Click(object sender, EventArgs e)
        {
            this.spokeCountNumericUpDown.Value        = 9;
            this.spokeThicknessNumericUpDown.Value    = 4;
            this.innerCircleRadiusNumericUpDown.Value = 6;
            this.outerCircleRadiusNumericUpDown.Value = 7;
            this.rotationSpeedNumericUpDown.Value     = 80;
        }

        #endregion
        #region IE7 스타일 버튼 클릭시 처리하기 - ie7StyleButton_Click(sender, e)

        /// <summary>
        /// IE7 스타일 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void ie7StyleButton_Click(object sender, EventArgs e)
        {
            this.spokeCountNumericUpDown.Value        = 36;
            this.spokeThicknessNumericUpDown.Value    = 4;
            this.innerCircleRadiusNumericUpDown.Value = 8;
            this.outerCircleRadiusNumericUpDown.Value = 9;
            this.rotationSpeedNumericUpDown.Value     = 20;
        }

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

댓글을 달아 주세요