728x90
728x170
▶ MainForm.cs
using System;
using System.Drawing;
using System.Windows.Forms;
using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 타이머
/// </summary>
private Timer timer;
/// <summary>
/// 난수기
/// </summary>
private Random random = new Random();
/// <summary>
/// 화살 시리즈
/// </summary>
private Arrow arrow;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
Text = "Arrow 클래스 사용하기";
this.timer = new Timer();
this.timer.Interval = 1;
this.tChart.Panel.Pen = new ChartPen(Color.Black);
this.tChart.Aspect.View3D = true;
this.tChart.Aspect.Orthogonal = false;
this.tChart.Aspect.Perspective = 50;
this.tChart.Aspect.Rotation = 350;
this.tChart.Aspect.Elevation = 350;
this.tChart.Aspect.Zoom = 90;
this.tChart.Legend.Visible = false;
this.arrow = new Arrow(this.tChart.Chart);
this.arrow.ColorEach = true;
this.arrow.ArrowWidth = 32;
this.arrow.ArrowHeight = 24;
this.arrow.ColorEach = true;
AddRandomArrows();
FormClosing += Form_FormClosing;
this.timer.Tick += timer_Tick;
this.timer.Start();
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 폼을 닫을 경우 처리하기 - Form_FormClosing(sender, e)
/// <summary>
/// 폼을 닫을 경우 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
this.timer.Stop();
}
#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.timer.Stop();
for(int i = 0; i < this.arrow.Count; i++)
{
this.arrow.StartXValues[i] = this.arrow.StartXValues[i] + this.random.Next(100) - 50;
this.arrow.StartYValues[i] = this.arrow.StartYValues[i] + this.random.Next(100) - 50;
this.arrow.EndXValues[i] = this.arrow.EndXValues[i] + this.random.Next(100) - 50;
this.arrow.EndYValues[i] = this.arrow.EndYValues[i] + this.random.Next(100) - 50;
}
this.arrow.Repaint();
this.timer.Start();
}
#endregion
//////////////////////////////////////////////////////////////////////////////// Function
#region 임의 화살표 추가하기 - AddRandomArrows()
/// <summary>
/// 임의 화살표 추가하기
/// </summary>
private void AddRandomArrows()
{
double x0;
double y0;
double x1;
double y1;
this.arrow.Clear();
for(int i = 1; i < 40; i++)
{
x0 = this.random.Next(1000);
y0 = this.random.Next(1000);
x1 = this.random.Next(300) - 150;
if(x1 < 50)
{
x1 = 50;
}
x1 += x0;
y1 = this.random.Next(300) - 150;
if(y1 < 50)
{
y1 = 50;
}
y1 += y0;
this.arrow.Add(x0, y0, x1, y1);
}
}
#endregion
}
}
728x90
그리드형(광고전용)
'TeeChart > WinForm' 카테고리의 다른 글
[TEECHART/WINFORM] Shape 클래스 : VertAlignment 속성을 사용해 텍스트 정렬하기 (0) | 2022.03.24 |
---|---|
[TEECHART/WINFORM] Shape 클래스 : Brush 속성을 사용해 브러시 이미지 설정하기 (0) | 2022.03.24 |
[TEECHART/WINFORM] Shape 클래스 : Style 속성을 사용해 도형 추가하기 (0) | 2022.03.24 |
[TEECHART/WINFORM] Gantt 클래스 : Add/AddMultipleNextTasks 메소드 사용하기 (0) | 2022.03.24 |
[TEECHART/WINFORM] Gantt 클래스 사용하기 (0) | 2022.03.24 |
[TEECHART/WINFORM] Points 클래스 : GetVertAxis 필드를 사용해 Y축 설정하기 (0) | 2022.03.24 |
[TEECHART/WINFORM] Points 클래스 사용하기 (0) | 2022.03.24 |
[TEECHART/WINFORM] HorizBar 클래스 : MultiBar/BarStyle 속성을 사용해 스택 수평 바 차트 만들기 (0) | 2022.03.23 |
[TEECHART/WINFORM] HorizLine 클래스 : Stairs 속성을 사용해 계단형 수평 라인 차트 만들기 (0) | 2022.03.23 |
[TEECHART/WINFORM] HorizArea 클래스 : MultiArea/Stairs 속성을 사용해 계단형 스택 수평 영역 차트 만들기 (0) | 2022.03.23 |