本示例演示了在窗体上绘制曲线的多种不同方法。示例
复制代码
System.Drawing.Graphics formGraphics = this.CreateGraphics();
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Black);// Draw head with an ellipse.
formGraphics.DrawEllipse(myPen, 0, 0, 200, 200);// Draw winking eye with an arc.
formGraphics.DrawArc(myPen, 40, 40, 40, 40, 180, -180);// Draw open eye with an ellipse.
formGraphics.DrawEllipse(myPen, 120, 40, 40, 40);// Draw nose with a Bezier spline.
formGraphics.DrawBezier(myPen, 100, 60, 120, 100, 90, 120, 80, 100);// Draw mouth with a canonical spline.
Point[] apt = new Point[4];
apt[0] = new Point(60, 140);
apt[1] = new Point(140, 140);
apt[2] = new Point(100, 180);
apt[3] = new Point(60, 140);
formGraphics.DrawCurve(myPen, apt, 0, 3, 0.9f);myPen.Dispose();
formGraphics.Dispose();
编译代码
此示例需要:一个 Windows 窗体应用程序项目,其中带有一个名为 formGraphics 的窗体。此代码必须处于 Form 类的范围内。该窗体的实例由 this 表示。
============================================================================================
问一下这个窗体怎么添加
复制代码
System.Drawing.Graphics formGraphics = this.CreateGraphics();
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Black);// Draw head with an ellipse.
formGraphics.DrawEllipse(myPen, 0, 0, 200, 200);// Draw winking eye with an arc.
formGraphics.DrawArc(myPen, 40, 40, 40, 40, 180, -180);// Draw open eye with an ellipse.
formGraphics.DrawEllipse(myPen, 120, 40, 40, 40);// Draw nose with a Bezier spline.
formGraphics.DrawBezier(myPen, 100, 60, 120, 100, 90, 120, 80, 100);// Draw mouth with a canonical spline.
Point[] apt = new Point[4];
apt[0] = new Point(60, 140);
apt[1] = new Point(140, 140);
apt[2] = new Point(100, 180);
apt[3] = new Point(60, 140);
formGraphics.DrawCurve(myPen, apt, 0, 3, 0.9f);myPen.Dispose();
formGraphics.Dispose();
编译代码
此示例需要:一个 Windows 窗体应用程序项目,其中带有一个名为 formGraphics 的窗体。此代码必须处于 Form 类的范围内。该窗体的实例由 this 表示。
============================================================================================
问一下这个窗体怎么添加
解决方案 »
- 问下Video video = new Video(open.FileName,false); 应用程序中的错误”怎么解决,求助
- 如何去掉多余引用的DLL
- 用C#实现voronoi算法
- C# 如何实现这样的数组,用二维数组作为一维数组的子项
- c#+短信猫 开发短信系统 研发成功 散分。。。。散分。。。。。 顶者有分
- 怎么把toolstripcombobox的背景调成透明的
- 关于静态变量值的问题
- 很傻的问题 C# 中怎么取当前时间?
- 孟子,思归,速马请看一下,读取远程xml的问题
- TrackBar控件中那个滑动块 怎么改颜色?
- Datagridview如果查询没有信息怎么返回上一次查询的信息
- 在C#winform中如何关闭指定窗体?
用类似于Form1 formGraphics=new Form1(); 这样的方式来创建。
那如何创建一个Paint事件呢,我在窗体的属性中没找到
链接在这里,我对你最开始的回复有点不太明白,我想知道怎么通过你最初描述的方法来实现绘图,而不是通过事件