圆角Panel
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing; namespace POS.Controls
{
public partial class PosPanel : Panel
{
public PosPanel()
{
InitializeComponent();
} private int mMatrixRound = ;
private Color mBack; public Color Back
{
get { return mBack; }
set
{
if (value == null)
{
mBack = Control.DefaultBackColor;
}
else
{
mBack = value;
}
base.Refresh();
}
} public int MatrixRound
{
get { return mMatrixRound; }
set
{
mMatrixRound = value;
base.Refresh();
}
} private GraphicsPath CreateRound(Rectangle rect, int radius)
{
GraphicsPath roundRect = new GraphicsPath();
//顶端
roundRect.AddLine(rect.Left + radius - , rect.Top - , rect.Right - radius, rect.Top - );
//右上角
roundRect.AddArc(rect.Right - radius, rect.Top - , radius, radius, , );
//右边
roundRect.AddLine(rect.Right, rect.Top + radius, rect.Right, rect.Bottom - radius);
//右下角 roundRect.AddArc(rect.Right - radius, rect.Bottom - radius, radius, radius, , );
//底边
roundRect.AddLine(rect.Right - radius, rect.Bottom, rect.Left + radius, rect.Bottom);
//左下角
roundRect.AddArc(rect.Left - , rect.Bottom - radius, radius, radius, , );
//左边
roundRect.AddLine(rect.Left - , rect.Top + radius, rect.Left - , rect.Bottom - radius);
//左上角
roundRect.AddArc(rect.Left - , rect.Top - , radius, radius, , );
return roundRect;
} protected override void OnPaint(PaintEventArgs e)
{
int width = base.Width - base.Margin.Left - base.Margin.Right;
int height = base.Height - base.Margin.Top - base.Margin.Bottom;
Rectangle rec = new Rectangle(base.Margin.Left, base.Margin.Top, width, height);
GraphicsPath round = CreateRound(rec, mMatrixRound);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.FillPath((Brush)(new SolidBrush(mBack)), round);
}
}
}
使用的时候背景颜色设为透明,Back是前景色,设一个不同的颜色。就OK了
圆角Panel的更多相关文章
- 用Delphi画圆角Panel的方法(使用CreateRoundRectRgn创造区域,SetWindowRgn显示指定区域)
用Delphi画圆角Panel的方法: procedure TForm1.Button5Click(Sender: TObject);var fhr :Thandle;beginfhr:=Create ...
- C# 用户控件之温度计
本文以一个用户控件[User Control]实现温度计的小例子,简述用户控件的相关知识,以供学习分享使用,如有不足之处,还请指正. 概述 一般而言,用户控件[User Control],是在Visu ...
- C#用户自定义控件(含源代码)-透明文本框
using System; using System.Collections; using System.ComponentModel; using System.Drawing; using Sys ...
- 【控件扩展】带圆角、边框、渐变的panel
下载地址: http://files.cnblogs.com/chengulv/custompanel_demo.zip using System; namespace LC.Fun { /// & ...
- Panel扩展 圆角边框,弧形边框
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...
- winfrom组件圆角
精简后,就其实一点,只要有paint事件的组件,都可画圆角,没有的外面套一个panel就行了. using System; using System.Collections.Generic; usin ...
- 初学c# -- 学习笔记(六) winfrom组件圆角
刚好用到这个功能,看了好些例子.我就不明白,简单的一个事,一些文章里的代码写的那个长啊,还让人看么. 精简后,就其实一点,只要有paint事件的组件,都可画圆角,没有的外面套一个panel就行了. u ...
- jQuery Moblie 学习之page、button、theme、panel、listview、controlgroup、navbar等(一)
1.jQTouch jQTouch与jQuery Moblie十分相似,也是一个jQuery插件,同样也支持HTML页面标签驱动,实现移动设备视图切换效果.不同的是它是专为WebKit内核的浏览器打造 ...
- Ext.Panel的主要功能
介绍面板组件的主要配置项及经常用法,这些配置项及方法将在后面的演示样例中用到,能够把这部分内容作为兴许章节的铺垫,进行高速的浏览,Ext.Panel主要配置项目如表5-1所看到的. 表5-1 Ext ...
随机推荐
- nginx重新编译安装upload模块
由于php处理上传会出现超时,并且显示上传进度官方php不支持nginx+php,所以决定让nginx自己处理上传,我本地环境是mac上已经安装过nginx1.8.0,安装方式为brew,所以需要重新 ...
- [LeetCode] 164. 最大间距
题目链接 : https://leetcode-cn.com/problems/maximum-gap/ 题目描述: 给定一个无序的数组,找出数组在排序之后,相邻元素之间最大的差值. 如果数组元素个数 ...
- [LeetCode] 140. 单词拆分 II
题目链接 : https://leetcode-cn.com/problems/word-break-ii/ 题目描述: 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,在字符 ...
- 好用的 Puppeteer 辅助工具 Puppeteer Recorder
Puppeteer Puppeteer 是一个Node库,它提供了一个高级API来控制DevTools协议上的Chrome或Chromium,常用于爬虫.自动化测试等,你在浏览器手动完成的大多数事情都 ...
- js模拟自动化测试 -- 多用户登录
1.核心登录提交方法 /** * 动态表单提交方法 * @param url{string}: 提交地址 * @param params{object}: 要提交的表单数据 **/ function ...
- P2218 [HAOI2007]覆盖问题
传送门 首先可以想到二分答案,然后考虑判断 注意到所有点的外包矩形的四条边一定要被覆盖到,而正方形只有 $3$ 个,所以一定有一个正方形在角落 考虑爆搜,枚举正方形在当前外包矩形的那个角,然后对剩下的 ...
- C#选择文件返回缩略图
传入文件路径,返回临时文件中缩略图的路径,jpg,pdf,office,rar都行 string path = ThumbnailHelper.GetInstance().GetJPGThumbnai ...
- Linux下安装chrome浏览器
第一步:进入google-chrome官网下载chrome安装包 官网地址:https://www.google.cn/chrome/ 选择要下载的安装包 注意:这里有两个选项,请按照你安装的系统下载 ...
- HMP许可更新
1.打开HMP License Manager,显示路径(License File Name)下的文件为最新许可,点击Activate License后,点击Show License Details, ...
- 手写与copy
m_Font.CreateFont( 14, // 字体高度 0 , // 宽度由系统确定 0 , // 文本不倾斜 0 , // 字体不倾斜 FW_NORMAL, // 字体粗度 0 , // 非斜 ...