winform GDI基础(二)画带圆角的矩形框
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;//去掉锯齿
g.CompositingQuality = CompositingQuality.HighQuality;//合成图像的质量
g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;//去掉文字的锯齿
System.Drawing.Pen p = new System.Drawing.Pen(Color.FromArgb(255, 146, 126, 102), 2); drawRoundedRect(g, p, 20, 20, 200, 200, 20);
} /// <summary>
/// 带圆角矩形
/// </summary>
/// <param name="radius">圆角半径</param>
private void drawRoundedRect(Graphics g, System.Drawing.Pen pen, int x, int y, int width, int height, int radius)
{
//去掉圆角的锯齿
g.SmoothingMode = SmoothingMode.HighQuality; //上
g.DrawLine(pen, new PointF(x + radius, y), new PointF(x + width - radius, y));
//下
g.DrawLine(pen, new PointF(x + radius, y + height), new PointF(x + width - radius, y + height));
//左
g.DrawLine(pen, new PointF(x, y + radius), new PointF(x, y + height - radius));
//右
g.DrawLine(pen, new PointF(x + width, y + radius), new PointF(x + width, y + height - radius)); //左上角
g.DrawArc(pen, new Rectangle(x, y, radius * 2, radius * 2), 180, 90);
//右上角
g.DrawArc(pen, new Rectangle(x + width - radius * 2, y, radius * 2, radius * 2), 270, 90);
//左下角
g.DrawArc(pen, new Rectangle(x, y + height - radius * 2, radius * 2, radius * 2), 90, 90);
//右下角
g.DrawArc(pen, new Rectangle(x + width - radius * 2, y + height - radius * 2, radius * 2, radius * 2), 0, 90);
}
winform GDI基础(二)画带圆角的矩形框的更多相关文章
- winform GDI基础(一)
1获取画布 (1)从PaintEventArgs类中获取画布 private void Form1_Paint(object sender, PaintEventArgs e) { Graphics ...
- Winform GDI+绘图二:绘制旋转太极图
大家好,今天有时间给大家带来Winform自绘控件的第二部分,也是比较有意思的一个控件:旋转太极图. 大家可以停下思考一下,如果让你来绘制旋转的太极图,大家有什么样的思路呢?我今天跟大家展示一下,我平 ...
- winform GDI基础(四)简单截屏
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); G ...
- winform GDI基础(三)实现画笔
在程序窗口上使用鼠标画图 private Point pStart, pEnd; private bool isAllowDraw = false; private bool isOpenPen = ...
- Win32 GDI基础(笔记)
1.GDI名字的意义 GDI Graphic Device Interface,我说不清和GUI有什么区别.可能一种针对设备,一种针对用户而言吧,反正以后都说GDI,也就是Windows的图形编程. ...
- 《C# GDI+ 破境之道》:第一境 GDI+基础 —— 第三节:画圆形
有了上一节画矩形的基础,画圆形就不要太轻松+EZ:)所以,本节在画边线及填充上,就不做过多的讲解了,关注一下画“随机椭圆”.“正圆”.“路径填充”的具体实现就好.与画矩形相比较,画椭圆与之完全一致,没 ...
- WinForm GDI+ 资料收集
UI(User Interface)编程在整个项目开发过程中是个颇为重要的环节,任何好的解决方案若没有良好的用户界面呈现给最终用户,那么就算包含了最先进的技术也不能算是好程序.UI编程体现在两个方面, ...
- CSS 奇思妙想 | 巧妙的实现带圆角的三角形
之前在这篇文章中 -- <老生常谈之 CSS 实现三角形>,介绍了 6 种使用 CSS 实现三角形的方式. 但是其中漏掉了一个非常重要的场景,如何使用纯 CSS 实现带圆角的三角形呢?,像 ...
- Bootstrap <基础二十二>超大屏幕(Jumbotron)
Bootstrap 支持的另一个特性,超大屏幕(Jumbotron).顾名思义该组件可以增加标题的大小,并为登陆页面内容添加更多的外边距(margin).使用超大屏幕(Jumbotron)的步骤如下: ...
随机推荐
- Linux网络编程学习路线
转载自:https://blog.csdn.net/lianghe_work/article 一.网络应用层编程 1.Linux网络编程01——网络协议入门 2.Linux网络编程02——无连接和 ...
- 服务监控Zabbix和Nagios的继任者
本文转载自:https://blog.csdn.net/moonpure/article/details/78633668 为了调研市场,从而做出更好的监控工具,David Gildeh 曾采访了超过 ...
- LeetCode第一题:Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...
- mongodb collection method
https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/ db.coll_test.getIndexes()# ...
- jenkins学习 02 jenkins安装与配置
1: Jenkins安装 在最简单的情况下,Jenkins 只需要两个步骤: (1)下载最新的版本(一个 WAR 文件).Jenkins官方网址: http://Jenkins-ci.org/ (2 ...
- JAVA基础知识(13)-----Lock接口
Lock接口:多线程在JDK1.5版本升级时,推出一个接口Lock接口.解决线程安全问题使用同步的形式,(同步代码块,要么同步函数)其实最终使用的都是锁机制. 到了后期版本,直接将锁封装成了对象.线程 ...
- C语言生成程序问题
问题: 我用VS2013写好C语言程序调试运行后就在debug文件夹下生成了EXE文件,可以在本机运行.但是这个EXE文件在别的没装过VS2013的电脑上就不能直接运行,说丢失MSVCR120D.dl ...
- Debian7 apt源设置
刚装完系统时是没有 apt-spy 的,这时候我们可以暂时先找个可用的源代替,如(写在 /etc/apt/sources.list 中): deb http://http.us.debian.org/ ...
- 第六章 Java并发容器和框架
ConcurrentHashMap的实现原理与使用 ConcurrentHashMap是线程安全且高效的hashmap.本节让我们一起研究一下该容器是如何在保证线程安全的同时又能保证高效的操作. 为什 ...
- nginx 添加win 服务
https://jingyan.baidu.com/article/0964eca279aa818285f536a9.html