欢迎访问 生活随笔!

尊龙游戏旗舰厅官网

当前位置: 尊龙游戏旗舰厅官网 > 编程语言 > c# >内容正文

c#

c#:绘制winform窗体 -尊龙游戏旗舰厅官网

发布时间:2025/1/21 c# 31 豆豆
尊龙游戏旗舰厅官网 收集整理的这篇文章主要介绍了 c#:绘制winform窗体 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

 

winform窗体缺少左上角效果:

public void setwindowregion(){system.drawing.drawing2d.graphicspath formpath;formpath = new system.drawing.drawing2d.graphicspath();rectangle rect = new rectangle(0, 0, this.width, this.height);int diameter = 20;formpath .addrectangle(new rectangle(rect.location.x diameter, rect.location.y, rect.width - diameter, rect.height));formpath .addrectangle(new rectangle(rect.location.x, rect.location.y diameter, diameter, rect.height - diameter));path.closefigure();this.region = new region(formpath);}protected override void onresize(system.eventargs e){this.region = null;setwindowregion();} view code

 


参考:winform窗体四圆角效果:

public void setwindowregion(){system.drawing.drawing2d.graphicspath formpath;formpath = new system.drawing.drawing2d.graphicspath();rectangle rect = new rectangle(0, 22, this.width, this.height - 22);//this.left-10,this.top-10,this.width-10,this.height-10); formpath = getroundedrectpath(rect, 30);this.region = new region(formpath);}private graphicspath getroundedrectpath(rectangle rect, int radius){int diameter = radius;rectangle arcrect = new rectangle(rect.location, new size(diameter, diameter));graphicspath path = new graphicspath();// 左上角 path.addarc(arcrect, 180, 90);// 右上角 arcrect.x = rect.right - diameter;path.addarc(arcrect, 270, 90);// 右下角 arcrect.y = rect.bottom - diameter;path.addarc(arcrect, 0, 90);// 左下角 arcrect.x = rect.left;path.addarc(arcrect, 90, 90);path.closefigure();return path;}protected override void onresize(system.eventargs e){this.region = null;setwindowregion();} view code

 

总结

以上是尊龙游戏旗舰厅官网为你收集整理的c#:绘制winform窗体的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得尊龙游戏旗舰厅官网网站内容还不错,欢迎将尊龙游戏旗舰厅官网推荐给好友。

网站地图