Social Icons

Sunday, April 25, 2010

Drawing Pie Chart

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 DrawingPieShapes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btn_show_Click(object sender, EventArgs e)
{
// Create a Graphics object
Graphics g = this.CreateGraphics();
g.Clear(this.BackColor);

// get the current value of start and sweep angles
float startAngle = (float)Convert.ToDouble(textBox1.Text);
float sweepAngle = (float)Convert.ToDouble(textBox2.Text);

// Create a pen
Pen writePen = new Pen(Color.Blue, 1);

// Draw pie
g.DrawPie(writePen, 20, 20, 100, 100, startAngle, sweepAngle);

// dispose of objects
writePen .Dispose();
g.Dispose();
}
}
}

No comments:

Post a Comment

 

Sample text

Sample Text