• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >C#教程 > C#画圆角矩形的方法

C#画圆角矩形的方法

作者:xujh 字体:[增加 减小] 来源:互联网 时间:2017-05-28

xujh 通过本文主要向大家介绍了c#绘制圆角矩形,c#画圆角矩形,c#圆角矩形,c#button圆角,c#窗体圆角等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了C#画圆角矩形的方法。分享给大家供大家参考。具体实现方法如下:

protected void Page_Load(object sender, EventArgs e)
{
 Bitmap bm = new Bitmap(800, 600);
 Graphics g = Graphics.FromImage(bm);
 g.FillRectangle(Brushes.White,new Rectangle(0,0,800,600));
 FillRoundRectangle(g,Brushes.Plum,new Rectangle(100, 100, 100, 100), 8);
 DrawRoundRectangle(g, Pens.Yellow,new Rectangle(100, 100, 100, 100), 8);
 bm.Save(Response.OutputStream, ImageFormat.Jpeg);
 g.Dispose();
 bm.Dispose();
}
public static void DrawRoundRectangle(Graphics g,Pen pen,Rectangle rect, int cornerRadius)
{
 using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
 {
  g.DrawPath(pen, path);
 }
}
public static void FillRoundRectangle(Graphics g, Brush brush,Rectangle rect, int cornerRadius)
{
 using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
 {
  g.FillPath(brush, path);
 }
}
internal static GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius)
{
 GraphicsPath roundedRect = new GraphicsPath();
 roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
 roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
 roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
 roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
 roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
 roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
 roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
 roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
 roundedRect.CloseFigure();
 return roundedRect;
}
</div>

希望本文所述对大家的C#程序设计有所帮助。

</div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • C#画圆角矩形的方法
  • C# 开发圆角控件(窗体)的具体实现

相关文章

  • 2017-05-28C# CheckedListBox控件的用法总结
  • 2017-05-28C#约瑟夫问题解决方法
  • 2017-05-28C#利用iTextSharp添加PDF水印
  • 2017-05-28C#中父窗口和子窗口之间控件互操作实例
  • 2017-05-28C#加密算法汇总(推荐)
  • 2017-05-28使用C#在注册表中保存信息的例子
  • 2017-05-28深入多线程之:深入分析Interlocked
  • 2017-05-28微信开放平台之网站授权微信登录功能
  • 2017-05-28C# 中GUID生成格式的四种方法
  • 2017-05-28二叉树的遍历算法(详细示例分析)

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • C# 基础入门--注释
    • C#引用类型转换的常见方式总结
    • C#实现json格式转换成对象并更换key的方法
    • C#通用邮件发送类分享
    • c#数字图像处理的3种方法示例分享
    • C#实现计算年龄的简单方法汇总
    • c#文件名/路径处理方法示例
    • C#中多态现象和多态的实现方法
    • 使用C#开源文件实时监控工具Tail&TailUI介绍
    • 枚举的用法详细总结

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有