[TEECHART/WINFORM] DrawLine 클래스 : Select/DraggedLine 이벤트를 사용해 라인 드래그하기
TeeChart/WinForm 2022. 3. 30. 15:13728x90
반응형
728x170
▶ 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
반응형
그리드형(광고전용)
'TeeChart > WinForm' 카테고리의 다른 글
[TEECHART/WINFORM] FullScreenTool 클래스 : 전체 화면 사용하기 (0) | 2022.03.30 |
---|---|
[TEECHART/WINFORM] FibonacciTool 클래스 사용하기 (0) | 2022.03.30 |
[TEECHART/WINFORM] FaderTool 클래스 사용하기 (0) | 2022.03.30 |
[TEECHART/WINFORM] ExtraLegend 클래스 : 추가 레전드 표시하기 (0) | 2022.03.30 |
[TEECHART/WINFORM] DrawLine 클래스 : EscapeKey 속성을 사용해 신규 라인 생성 취소하기 (0) | 2022.03.30 |
[TEECHART/WINFORM] DrawLine 클래스 : 라인 그리기 (0) | 2022.03.30 |
[TEECHART/WINFORM] DragPoint 클래스 : 포인트 드래그하기 (0) | 2022.03.29 |
[TEECHART/WINFORM] DragMarks 클래스 : 마커 드래그하기 (0) | 2022.03.29 |
[TEECHART/WINFORM] DataTableTool 클래스 사용하기 (0) | 2022.03.29 |
[TEECHART/WINFORM] ColorLine 클래스 : NoLimitDrag 속성을 사용해 축 제한 밖으로 드래그 가능하게 하기 (0) | 2022.03.28 |
댓글을 달아 주세요