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;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
int[] array = { 25, 15, 10, 30, 20 };
float sum = 0;
for (int i = 0; i < array.Length; i++)
{
sum += array[i];
}
Graphics g = e.Graphics;
SolidBrush brush = new SolidBrush(Color.Red);
g.FillPie(brush, new Rectangle(10, 10, 200, 200), 0, (float)array[0] * 360 / sum);
brush = new SolidBrush(Color.Blue);
g.FillPie(brush, new Rectangle(10, 10, 200, 200), (float)array[0] * 360 / sum, (float)array[1] * 360 / sum);
brush = new SolidBrush(Color.Green);
g.FillPie(brush, new Rectangle(10, 10, 200, 200), (float)(array[0] + array[1]) * 360 / sum,(float)array[2] * 360 / sum);
brush = new SolidBrush(Color.Yellow);
g.FillPie(brush, new Rectangle(10, 10, 200, 200),(float)(array[0] + array[1] + array[2]) * 360 / sum,(float)array[3] * 360 / sum);
brush = new SolidBrush(Color.White);
g.FillPie(brush, new Rectangle(10, 10, 200, 200),(float)(array[0] + array[1] + array[2] + array[3]) * 360 / sum,(float)array[4] * 360 / sum);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
int[] array = { 25, 15, 10, 30, 20 };
float sum = 0;
for (int i = 0; i < array.Length; i++)
{
sum += array[i];
}
Graphics g = e.Graphics;
SolidBrush brush = new SolidBrush(Color.Red);
g.FillPie(brush, new Rectangle(10, 10, 200, 200), 0, (float)array[0] * 360 / sum);
brush = new SolidBrush(Color.Blue);
g.FillPie(brush, new Rectangle(10, 10, 200, 200), (float)array[0] * 360 / sum, (float)array[1] * 360 / sum);
brush = new SolidBrush(Color.Green);
g.FillPie(brush, new Rectangle(10, 10, 200, 200), (float)(array[0] + array[1]) * 360 / sum,(float)array[2] * 360 / sum);
brush = new SolidBrush(Color.Yellow);
g.FillPie(brush, new Rectangle(10, 10, 200, 200),(float)(array[0] + array[1] + array[2]) * 360 / sum,(float)array[3] * 360 / sum);
brush = new SolidBrush(Color.White);
g.FillPie(brush, new Rectangle(10, 10, 200, 200),(float)(array[0] + array[1] + array[2] + array[3]) * 360 / sum,(float)array[4] * 360 / sum);
}
}
}