System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);//画笔
system.drawing.solidbrush mybrush = new system.drawing.solidbrush(system.drawing.color.red);//画刷
system.drawing.graphics formgraphics = this.creategraphics();
formgraphics.fillellipse(mybrush, new rectangle(0, 0, 100, 200));//画实心椭圆
formgraphics.drawellipse(mypen, new rectangle(0, 0, 100, 200));//空心圆
formgraphics.fillrectangle(mybrush, new rectangle(0, 0, 100, 200));//画实心方
formgraphics.drawrectangle(mypen, new rectangle(0, 0, 100, 200));//空心矩形
formgraphics.drawline(mypen, 0, 0, 200, 200);//画线
formgraphics.drawpie(mypen, 90, 80, 140, 40, 120, 100); //画馅饼图形
画多边形
formgraphics.drawpolygon(mypen, new point[]{
new point(30,140),
new point(270,250),
new point(110,240),
new point (200,170),
new point(70,350),
new point(50,200)
});
清理使用的资源
mypen.dispose();
mybrush.dispose();
formgraphics.dispose();