WINFORM学习手册——画线、椭圆、馅饼、多边形
一、线条:
/// <summary> /// 画直线 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PaintLine(object sender, PaintEventArgs e) { Pen pen = new Pen(Color.Red, 5);//创建一只红色的画笔 pen.DashStyle = DashStyle.Dash;//画笔样式,-.-.-.-.-.-. e.Graphics.DrawLine(pen, 60, 60, 100, 200); //直线的两头分别是(60,60)和(100,200) }
二、椭圆:
/// <summary> /// 画椭圆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PaintCircle(object sender, PaintEventArgs e) { Pen pen = new Pen(Color.Blue, 10);//创建一只蓝色的画笔 pen.DashStyle = DashStyle.DashDotDot;//画笔样式,-..-..-..-.. e.Graphics.DrawEllipse(pen, 70, 70, 50, 50); }
三、馅饼:
/// <summary> /// 画馅饼 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PaintPie(object sender, PaintEventArgs e) { Pen pen = new Pen(Color.Black, 1);//创建一只黑色的画笔 pen.DashStyle = DashStyle.Dot;//画笔样式,................ e.Graphics.DrawPie(pen, 90, 80, 140, 40, 120, 100); }
四、多边形: