天天看点

C#编程-133:绘制椭圆、弧、扇形

C#编程-133:绘制椭圆、弧、扇形
using System.Drawing;
using System.Windows.Forms;
 
namespace RectangleTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen pen = new Pen(Color.Orange,3);
            g.DrawRectangle(pen,10,10,100,50);
            g.DrawLine(pen,new Point(10,70) ,new Point(110,70));
 
            //startangle从X轴顺时针方向旋转起始角
            //sweepangle,起始角开始,顺时针方向旋转的角度,单位为度
            g.DrawArc(pen,0,50,200,200,0,180);//绘制弧
 
            g.DrawPie(pen,200,50,200,200,0,90);//绘制扇形
        }
    }
}