■ Arrow 클래스를 사용하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
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 } } |