첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.01MB

▶ MainForm.cs

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

using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;

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

        #region 생성자 - MainForm()

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

            Text = "TChart 클래스 : BeforeDraw/BeforeDrawAxes/BeforeDrawSeries/AfterDraw 이벤트 사용하기";

            this.beforeChartRadioButton.Checked = true;

            this.tChart.Panel.Pen = new ChartPen(Color.Black);

            Bar bar = new Bar(this.tChart.Chart);

            bar.FillSampleValues();
            
            this.beforeChartRadioButton.Click  += radioButton_Click;
            this.beforeAxisRadioButton.Click   += radioButton_Click;
            this.beforeSeriesRadioButton.Click += radioButton_Click;
            this.afterChartRadioButton.Click   += radioButton_Click;
            this.tChart.BeforeDraw             += tChart_BeforeDraw;
            this.tChart.BeforeDrawAxes         += tChart_BeforeDrawAxes;
            this.tChart.BeforeDrawSeries       += tChart_BeforeDrawSeries;
            this.tChart.AfterDraw              += tChart_AfterDraw;
        }

        #endregion

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

        #region 라디오 버튼 클릭시 처리하기 - radioButton_Click(sender, e)

        /// <summary>
        /// 라디오 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void radioButton_Click(object sender, EventArgs e)
        {
            this.tChart.Invalidate();
        }

        #endregion
        #region TChart 그리기 전 처리하기 - tChart_BeforeDraw(sender, graphics3D)

        /// <summary>
        /// TChart 그리기 전 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="graphics3D">그래픽스 3D</param>
        private void tChart_BeforeDraw(object sender, Graphics3D graphics3D)
        {
            if(this.beforeChartRadioButton.Checked)
            {
                DrawShape();
            }
        }

        #endregion
        #region TChart 축 그리기 전 처리하기 - tChart_BeforeDrawAxes(sender, graphics3D)

        /// <summary>
        /// TChart 축 그리기 전 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="graphics3D">그래픽스 3D</param>
        private void tChart_BeforeDrawAxes(object sender, Graphics3D graphics3D)
        {
            if(this.beforeAxisRadioButton.Checked)
            {
                DrawShape();
            }
        }

        #endregion
        #region TChart 시리즈 그리기 전 처리하기 - tChart_BeforeDrawSeries(sender, graphics3D)

        /// <summary>
        /// TChart 시리즈 그리기 전 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="graphics3D">그래픽스 3D</param>
        private void tChart_BeforeDrawSeries(object sender, Graphics3D graphics3D)
        {
            if(this.beforeSeriesRadioButton.Checked)
            {
                DrawShape();
            }
        }

        #endregion
        #region TChart 그리기 후 처리하기 - tChart_AfterDraw(sender, graphics3D)

        /// <summary>
        /// TChart 그리기 후 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="graphics3D">그래픽스 3D</param>
        private void tChart_AfterDraw(object sender, Graphics3D graphics3D)
        {
            if(this.afterChartRadioButton.Checked)
            {
                DrawShape();
            }
        }

        #endregion

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

        #region 도형 그리기 - DrawShape()

        /// <summary>
        /// 도형 그리기
        /// </summary>
        private void DrawShape()
        {
            this.tChart.Graphics3D.Pen.Style     = DashStyle.Dot;
            this.tChart.Graphics3D.Brush.Visible = true;
            this.tChart.Graphics3D.Brush.Color   = Color.FromArgb(243, 156, 53);

            this.tChart.Graphics3D.Ellipse
            (
                1,
                1,
                this.tChart.Graphics3D.Chart.Width - 1,
                this.tChart.Graphics3D.Chart.Height - 1
            );
        }

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

댓글을 달아 주세요