using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace Gid_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Draw(Rectangle rectangle, Graphics g, int _radius, bool cusp, Color begin_color, Color end_color)
{
int span = ;
//抗锯齿
g.SmoothingMode = SmoothingMode.AntiAlias;
//渐变填充
LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush(rectangle, begin_color, end_color, LinearGradientMode.Vertical);
//画尖角
if (cusp)
{
span = ;
PointF p1 = new PointF(rectangle.Width - , rectangle.Y + );
PointF p2 = new PointF(rectangle.Width - , rectangle.Y + );
PointF p3 = new PointF(rectangle.Width, rectangle.Y + );
PointF[] ptsArray = { p1, p2, p3 };
g.FillPolygon(myLinearGradientBrush, ptsArray);
}
//填充
g.FillPath(myLinearGradientBrush, DrawRoundRect(rectangle.X, rectangle.Y, rectangle.Width - span, rectangle.Height-, _radius));
}
public static GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius)
{
//四边圆角
GraphicsPath gp = new GraphicsPath();
gp.AddArc(x, y, radius, radius, , );
gp.AddArc(width - radius, y, radius, radius, , );
gp.AddArc(width - radius, height - radius, radius, radius, , );
gp.AddArc(x, height - radius, radius, radius, , );
gp.CloseAllFigures();
return gp;
} private void panel1_Paint(object sender, PaintEventArgs e)
{
Draw(e.ClipRectangle, e.Graphics, ,true, Color.FromArgb(, , ), Color.FromArgb(, , ));
base.OnPaint(e);
Graphics g = e.Graphics;
g.DrawString("其实我是个Panel", new Font("微软雅黑", , FontStyle.Regular), new SolidBrush(Color.White), new PointF(, ));
} private void panel2_Paint(object sender, PaintEventArgs e)
{
Draw(e.ClipRectangle, e.Graphics, , false, Color.FromArgb(, , ), Color.FromArgb(, , ));
base.OnPaint(e);
Graphics g = e.Graphics;
g.DrawString("其实我是个Panel", new Font("微软雅黑", , FontStyle.Regular), new SolidBrush(Color.White), new PointF(, ));
} private void button1_Paint(object sender, PaintEventArgs e)
{
Draw(e.ClipRectangle, e.Graphics, , false, Color.FromArgb(, , ), Color.FromArgb(, , ));
base.OnPaint(e);
Graphics g = e.Graphics;
g.DrawString("其实我是个按钮", new Font("微软雅黑", , FontStyle.Regular), new SolidBrush(Color.White), new PointF(, ));
} private void label1_Paint(object sender, PaintEventArgs e)
{
Draw(e.ClipRectangle, e.Graphics, , false, Color.FromArgb(, , ), Color.FromArgb(, , ));
base.OnPaint(e); Graphics g = e.Graphics;
g.DrawString("其实我是Label", new Font("微软雅黑", , FontStyle.Regular), new SolidBrush(Color.Black), new PointF(, ));
}
}
}

转 winfrom组件圆角的更多相关文章

  1. winfrom组件圆角

    精简后,就其实一点,只要有paint事件的组件,都可画圆角,没有的外面套一个panel就行了. using System; using System.Collections.Generic; usin ...

  2. 初学c# -- 学习笔记(六) winfrom组件圆角

    刚好用到这个功能,看了好些例子.我就不明白,简单的一个事,一些文章里的代码写的那个长啊,还让人看么. 精简后,就其实一点,只要有paint事件的组件,都可画圆角,没有的外面套一个panel就行了. u ...

  3. Winfrom实现圆角设计

    主要代码 public partial class Form1 : Form    {        public Form1()        {            InitializeComp ...

  4. 强大的代码生成工具MyGeneration

    强大的代码生成工具MyGeneration 转 MyGeneration是一个功能很强大的代码生成工具.通过编写包含各种类型脚本(C#,VB.Net,JScript,VBScript)的模板,通过数据 ...

  5. winfrom控件圆角

    刚好用到这个功能,看了好些例子.我就不明白,简单的一个事,一些文章里的代码写的那个长啊,还让人看么. 精简后,就其实一点,只要有paint事件的组件,都可画圆角,没有的外面套一个panel就行了. u ...

  6. winfrom 实现窗体圆角

    在窗体中加入一下代码 #region 窗体圆角的实现 private void ComFrmBase_Resize(object sender, EventArgs e) { if (this.Win ...

  7. Android之怎样用代码使编辑框等组件显示为圆角

    圆角button实现 圆角button大家很常见.有时候你可能会使用ps来加工圆角图片来实现想要的效果, 今天通过简短的代码来达到这样的效果.(由于这个跟project无关.仅仅是一种效果,所以我就单 ...

  8. uni-app视频组件设置圆角

    无法实现,建议写个image在中间位置加个播放按钮,点击播放跳转新页面只需要在跳转参数里面把视频链接加上,在onLoad里面获取视频链接,自动播放视频,很多app目前都是这样做的,关闭页面后视频会自动 ...

  9. WINFROM窗体实现圆角

    首先我们先看看效果图 接下来我们看看怎么实现 先把窗体的FromBorderStyle属性改成None. 接下来登录窗体代码代码: 添加一个窗体Paint事件,引用using System.Drawi ...

随机推荐

  1. c语言字符串分割函数(转)

    源:C语言实现split以某个字符分割一个字符串 void split(char *src, const char *separator, char **dest, int *num) { /* sr ...

  2. PHP技术知识点整理

    1.解释mvc (1)mvc即 模型model,视图view,控制器controller:是一种模型,是一种编程思想,就是把一个应用的输入.输出.数据处理分开,分解耦合(2)A..视图,数据采集和处理 ...

  3. PHP使用MongoDB类操作MongoDB数据库总结

    参考:https://www.php.net/manual/zh/class.mongodb-driver-manager.php 参考:https://www.zhaokeli.com/articl ...

  4. typeScript模块<三>

    /*模块 1 模块的的概念 2 模块导出的几种方法 1.export 导出声明 2.export 导出语句 3.export default 4.import导入模块 3 模块化封装上一讲的DB库 * ...

  5. 【转载】 tf.split函数的用法

    原文地址: https://blog.csdn.net/uestc_c2_403/article/details/73350457 由于tensorflow 版本更新问题   用法略有修改 ----- ...

  6. oracle11g 查询临时表空间的使用率和正在使用临时表空间的用户

    转: oracle11g 查询临时表空间的使用率和正在使用临时表空间的用户 原创 Oracle 作者:记录每一次错误 时间:2018-12-21 15:46:33 11179 0 今天开发反映说临时表 ...

  7. Swift 4.0 + Ipad开发项目中值得注意知识点

    1.注意Xib的约束和代码的约束,注意适配问题: 2.设置view的frame可以使用view.frame.maxX实现布局: 3.UIStackView在xib中的使用,可以很好的实现约束,布局和屏 ...

  8. 第07组 Alpha冲刺(3/4)

    队名:秃头小队 组长博客 作业博客 组长徐俊杰 过去两天完成的任务:完成人员分配,初步学习Android开发 Github签入记录 接下来的计划:继续完成Android开发的学习,带领团队进行前后端开 ...

  9. java学习笔记(6)-多线程(1)

    标签(空格分隔): 笔记 一.基本概念 1.1 程序.进程.线程 程序(program):是为完成特定任务.用某种语言编写的一组指令的集合.即指一段静态的代码,静态对象. 进程(process):是程 ...

  10. python开发【学习目录】:目录

    python开发[学习目录]:目录 Python开发:环境搭建(python3.PyCharm) Python开发[第一篇]:初识Python Python开发[第二篇]:Python基础知识 Pyt ...