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

TestProject.zip
0.01MB

▶ 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
그리드형(광고전용)
Posted by icodebroker
,