WinForm绘制圆角的方法
程序员文章站
2023-08-17 16:33:04
本文实例讲述了winform绘制圆角的方法。分享给大家供大家参考。具体实现方法如下:
using system;
using system.collection...
本文实例讲述了winform绘制圆角的方法。分享给大家供大家参考。具体实现方法如下:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.runtime.interopservices; using system.drawing.drawing2d; namespace appstartsample { public partial class form3 : form { public form3() { initializecomponent(); } private void button1_click(object sender, eventargs e) { } private void button2_click(object sender, eventargs e) { } 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);// 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 - 0; 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(); } } }
希望本文所述对大家的c#程序设计有所帮助。
上一篇: 关于ASP网页无法打开的解决方案
下一篇: 高血糖能吃什么水果,该怎么样去预防呢