社区
C#
帖子详情
在.NET下,如何画圆角矩形? -=100分=-
Colin-Han
2006-04-13 08:12:57
如题。
...全文
309
3
打赏
收藏
在.NET下,如何画圆角矩形? -=100分=-
如题。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
copico
2006-04-13
打赏
举报
回复
画弧+四条边
代码蜗牛sky
2006-04-13
打赏
举报
回复
protected override void OnPaintBackground(PaintEventArgs pevent)
{
//填充大的圆角矩形框
Graphics g = pevent.Graphics;
g.FillRectangle( Brushes.Lime, 0, 0, this.ClientSize.Width, this.ClientSize.Height );
System.Drawing.Drawing2D.GraphicsPath framePath = Utils.CreateRoundedRectPath(this.ClientRectangle, 5 );
using ( System.Drawing.Drawing2D.LinearGradientBrush frameLgb =
new System.Drawing.Drawing2D.LinearGradientBrush( this.ClientRectangle,
Color.SteelBlue, Color.LightBlue, System.Drawing.Drawing2D.LinearGradientMode.Vertical ) )
{
g.FillPath( frameLgb, framePath );
}
//填充小的圆角矩形框:文本区
Rectangle textAreaRectangle = new Rectangle(this.ClientRectangle.Location.X + 5,
this.ClientRectangle.Location.Y + 5,this.ClientRectangle.Size.Width - 10,
this.ClientRectangle.Size.Height - 10);
System.Drawing.Drawing2D.GraphicsPath textAreaPath = Utils.CreateRoundedRectPath(textAreaRectangle,5);
g.FillPath( Brushes.White, textAreaPath );
}
代码蜗牛sky
2006-04-13
打赏
举报
回复
public static GraphicsPath CreateRoundedRectPath( Rectangle rect, int radius )
{
GraphicsPath rectPath = new GraphicsPath();
// Add the line on the top:
rectPath.AddLine( rect.Left + radius, rect.Top,
rect.Right - radius, rect.Top );
// Add the arc at the top right corner:
rectPath.AddArc( rect.Right - 2 * radius, rect.Top,
radius * 2, radius * 2 ,
270, 90 );
// Line down the right:
rectPath.AddLine( rect.Right, rect.Top + radius,
rect.Right, rect.Bottom - 10 );
// Bottom Right quarter circle:
rectPath.AddArc( rect.Right - radius * 2, rect.Bottom - radius * 2,
radius * 2, radius * 2,
0, 90 );
// bottom line:
rectPath.AddLine( rect.Right - 2 * radius, rect.Bottom ,
rect.Left + radius, rect.Bottom );
// Bottom left quarter circle:
rectPath.AddArc( rect.Left, rect.Bottom - 2 * radius,
2 * radius, 2 * radius, 90, 90 );
// Up the left side:
rectPath.AddLine( rect.Left, rect.Bottom - radius,
rect.Left, rect.Top + radius );
// Upper left arc:
rectPath.AddArc( rect.Left, rect.Top,
2 * radius, 2 * radius, 180, 90 );
return rectPath;
}
绘制
圆角
panel
.net
制作
圆角
panel的源码
在这个`OnPaint`方法中,我们首先创建了一个`GraphicsPath`对象来描述
圆角
矩形
的路径,然后使用`Graphics`对象进行绘制。我们通过调整`AddArc`方法的参数来指定每个角落的弧度,从而实现
圆角
效果。最后,我们根据...
VB
.NET
让窗体的图片变成
圆角
### VB
.NET
让窗体的图片变成
圆角
在日常的软件开发中,美观的界面设计对于提升用户体验具有重要作用。其中一种常见的美化方法是将窗口的边角处理成
圆角
形式,这不仅可以使界面看起来更加柔和,还可以为应用程序...
Android OpenGL ES绘制
圆角
矩形
演示demo源码
Android OpenGL ES绘制
圆角
矩形
演示demo源码 绘制
圆角
,详解见https://blog.csdn
.net
/github_27263697/article/details/143981399?... 目录 1、绘制
矩形
Renderer基类
矩形
Renderer类 ...3、绘制
圆角
矩形
...
.Net
绘制
圆角
窗体
在
.NET
框架中,实现
圆角
窗体是一种常见的UI设计需求,尤其在追求现代感与用户友好体验的应用程序中。本文将深入探讨如何利用C#语言和
.NET
中的绘图功能来创建具有
圆角
边框的窗体,这不仅能够提升应用程序的外观质量,...
WPF
圆角
矩形
.zip
在WPF中,我们可以通过XAML语言来声明式地定义UI元素及其属性,其中包括
圆角
矩形
的创建。这个“WPF
圆角
矩形
.zip”压缩包可能包含了一个简单的WPF应用示例,展示了如何利用C#编程和XAML来实现类似小米新Logo的
圆角
...
C#
111,120
社区成员
642,537
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章