C# graphics 方法
C#2010-05-07 09:30:57 阅读 467 评论 0 字号:大中小 订阅
命名空间:System.Drawing
程序集:System.Drawing(在 system.drawing.dll 中)
封装一个 GDI+ 绘图图面。无法继承此类。
C# 用法
public sealed class Graphics : MarshalByRefObject, IDeviceContext,
IDisposable
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();
评论2
最新资源