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

TestProject.zip
0.01MB

▶ MainForm.cs

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

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

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

        #region Field

        /// <summary>
        /// 라인
        /// </summary>
        private Line line;

        /// <summary>
        /// 라인 그리기
        /// </summary>
        private DrawLine drawLine;

        #endregion

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

        #region 생성자 - MainForm()

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

            Text = "DrawLine 클래스 : Select/DraggedLine 이벤트를 사용해 라인 드래그하기";

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

            this.line = new Line(this.tChart.Chart);

            this.line.FillSampleValues(30);

            this.drawLine = new DrawLine(this.tChart.Chart);

            this.drawLine.Pen.Width    = 2;
            this.drawLine.Pen.Color    = Color.Blue;
            this.drawLine.Active       = true;
            this.drawLine.EnableDraw   = true;
            this.drawLine.EnableSelect = true;
            this.drawLine.Button       = MouseButtons.Left;

            DrawLineItem item = new DrawLineItem(this.drawLine);

            double delta = line.YValues.Range / 5.0;

            item.StartPos = new PointDouble(5 , this.line.YValues.Maximum - delta);
            item.EndPos   = new PointDouble(15, this.line.YValues.Minimum + delta);

            this.drawLine.Select      += drawLine_Select;
            this.drawLine.DraggedLine += drawLine_DraggedLine;
            this.drawLine.NewLine     += drawLine_NewLine;
        }

        #endregion

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

        #region 라인 그리기 선택시 처리하기 - drawLine_Select(sender)

        /// <summary>
        /// 라인 그리기 선택시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        private void drawLine_Select(DrawLine sender)
        {
            SetLinePositionValueLebelData();
        }

        #endregion
        #region 라인 그리기 라인 드래그시 처리하기 - drawLine_DraggedLine(sender)

        /// <summary>
        /// 라인 그리기 라인 드래그시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        private void drawLine_DraggedLine(DrawLine sender)
        {
            SetLinePositionValueLebelData();
        }

        #endregion
        #region 라인 그리기 신규 라인 생성시 처리하기 - drawLine_NewLine(sender)

        /// <summary>
        /// 라인 그리기 신규 라인 생성시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        private void drawLine_NewLine(DrawLine sender)
        {
            SetLinePositionValueLebelData();
        }

        #endregion

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

        #region 라인 위치 값 레이블 데이터 설정하기 - SetLinePositionValueLebelData()

        /// <summary>
        /// 라인 위치 값 레이블 데이터 설정하기
        /// </summary>
        private void SetLinePositionValueLebelData()
        {
            DrawLineItem item = this.drawLine.Selected;

            this.linePositionValueLabel.Text = $"({item.StartPos.X:0.00}, {item.StartPos.Y:0.00}) - ({item.EndPos.X:0.00}, {item.EndPos.Y:0.00})";
        }

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

댓글을 달아 주세요