using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Chart_CSharp;

namespace LessonA22
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        XYChart chart;

        private void Form1_Load(object sender, EventArgs e)
        {
            chart = new XYChart(this.Handle);

            int nLen = 360;
            double[] pX = new double[nLen];
            double[] pY = new double[nLen];

            int i, j;
            Random rand = new Random();
            for (j = 19; j >= 0; j--)
            {
                for (i = 0; i < nLen; i++)
                {
                    pX[i] = i;
                    pY[i] = Math.Sin(i * 2.0 * 3.1415926536 / nLen * 5) / (1.0 + i * 4.0 / 359.0) / (j + 1.0) + (2.0 * rand.Next(100000) / 100000 - 1.0) * 0.04 / (j + 1.0);
                    if (pY[i] < 0.0) pY[i] = -pY[i];
                }
                chart.AddCurve(pX, pY, nLen);
            }


            chart.SetTitle("测试C#曲线图");
        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            chart.ReDraw();
        }
    }       
}
