GDI饼状图

GDI饼状图

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Drawing2D;

namespace App1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //定义起始高度和增量
        int y = 200;
        int i;
        //侧面
        private void Button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen pen = new Pen(Color.Gray, 3);
            for (i = 0; i < 40; i++)
            {
                g.DrawEllipse(pen, 250, y - i, 150, 80);
            }
        }
        //顶部
        private void Button2_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.FillEllipse(Brushes.White, 250, y - i, 150, 80);
        }
        //黄色
        private void Button3_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.FillPie(Brushes.Yellow, 250, y - i, 150, 80, 0, 120);
        }
        //蓝色
        private void Button4_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.FillPie(Brushes.Blue, 250, y - i, 150, 80, 120, 60);
        }
        //绿色
        private void Button5_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.FillPie(Brushes.Green, 250, y - i, 150, 80, 180, 180);
        }
    }
}
App1