最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
一个画任意形状的窗体的例子
时间:2022-07-02 11:35:21 编辑:袖梨 来源:一聚教程网
继承System.Windows.Forms.Form窗体类时,重载其画窗体形状的事件OnPaint,就可以画出各种自定义的窗体形状。例子代码是画一个圆形窗体。
protected override void OnPaint(PaintEventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(20,20,110,110);
//gp.AddLine(30,30,110,110);
Matrix RotationTransform = new Matrix(1,0, 0,1,1,1); // rotation matrix
//Matrix TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0); // translation matrix
PointF TheRotationPoint = new PointF(110.0f, 110.0f); // rotation point
// rotate the rotation transformation matrix f degrees around TheRotationPoint
RotationTransform.RotateAt(f, TheRotationPoint);
//Call the Transform method of the Graphics Path in order to multiply it by the rotation matrix and rotate the balloon
gp.Transform(RotationTransform);
e.Graphics.DrawPath(Pens.Black, gp);
f=f+10;
this.Region=new Region(gp);//这句是很重要的,设定窗体显示的区域为你所画的区域。
}
protected override void OnPaint(PaintEventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(20,20,110,110);
//gp.AddLine(30,30,110,110);
Matrix RotationTransform = new Matrix(1,0, 0,1,1,1); // rotation matrix
//Matrix TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0); // translation matrix
PointF TheRotationPoint = new PointF(110.0f, 110.0f); // rotation point
// rotate the rotation transformation matrix f degrees around TheRotationPoint
RotationTransform.RotateAt(f, TheRotationPoint);
//Call the Transform method of the Graphics Path in order to multiply it by the rotation matrix and rotate the balloon
gp.Transform(RotationTransform);
e.Graphics.DrawPath(Pens.Black, gp);
f=f+10;
this.Region=new Region(gp);//这句是很重要的,设定窗体显示的区域为你所画的区域。
}
相关文章
- 雪球官网网页版入口-雪球财经官网网页版 01-30
- 拷贝漫画2.1.0.4安卓下载入口-拷贝漫画2.1.0.4最新版本免费下载 01-30
- 有罪之身全集资源在线看-有罪之身最新一集免费观看入口地址 01-30
- 永劫无间云游戏入口-永劫无间无限畅玩云端官网 01-30
- 蓝莓影院官网入口-2026蓝莓影院电视剧免费观看 01-30
- 找靓机网页版直达-找靓机官网正版入口 01-30