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 System.Drawing.Drawing2D;

namespace Ex01_13
{
    public partial class Form1 : Form
    {

        int Sect = 20;
        float[] x = new float[31];
        float[] y = new float[31];

        public Form1()
        {
            InitializeComponent();
        }

        public void Mydraw()
        {
            int i;
            int Sect = 20;              //定义整形变量并赋值
            float r;
            float[] x = new float[31];      //定义浮点型变量数组
            float[] y = new float[31];
            this.ClientSize = new Size(200, 200);
            r = this.ClientSize.Width / 2;
            Graphics g = this.CreateGraphics();             //创建Graphics对象实例
            for (i = 0; i < Sect; i++)                     //利用For循环为数组赋值
            {
                x[i] = (float)(r * Math.Cos(i * 2 * Math.PI / Sect) + this.ClientSize.Width / 2);
                y[i] = (float)(r * Math.Sin(i * 2 * Math.PI / Sect) + this.ClientSize.Height / 2);
            }
            for (int m = 0; m < Sect - 1; m++)                     //利用双For循环绘制图案
            {
                for (int n = 0; n < Sect; n++)
                {
                    g.DrawLine(Pens.Red, x[m], y[m], x[n], y[n]);     //绘制红色的直线
                }
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.Clear(Color.Yellow);
            Mydraw();                                          //调用函数
          }

        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            this.Close();
        }

    






    }
}
