圆角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 ... 
随机推荐
- linux下安装msgpack,yar,phalcon
			安装msgpack扩展 下载:http://pecl.php.net/package/msgpack cd /usr/local tar zxvf msgpack-0.5.5.tgz cd msgpa ... 
- python递归方式和普通方式实现输出和查询斐波那契数列
			●斐波那契数列 斐波那契数列(Fibonacci sequence),是从1,1开始,后面每一项等于前面两项之和. 如果为了方便可以用递归实现,要是为了性能更好就用循环. ◆递归方式实现生成前30个斐 ... 
- 【问题解决方案】word2010中Mathtype公式偏上的问题解决
			参考百度百科 段落-中文版式-文本对齐方式-居中 END 
- POI读取文件的最佳实践
			POI是 Apache 旗下一款读写微软家文档声名显赫的类库.应该很多人在做报表的导出,或者创建 word 文档以及读取之类的都是用过 POI.POI 也的确对于这些操作带来很大的便利性.我最近做的一 ... 
- 使用Eclipse-Maven-git做Java开发(3)--Eclipse的安装和配
			使用Eclipse-Maven-git做Java开发(3)--Eclipse的安装和配 https://my.oschina.net/songxinqiang/blog/474530 
- SpringMVC设置不拦截静态资源css,js
			转自:https://blog.csdn.net/sh513023410/article/details/81361867 
- pandas 的index用途
			# pandas的索引index的用途 # 把数据存储于普通的column列也能用于数据查询,那使用index有什么好处? # 1.更方便的数据查询 # 2.使用index可以获得性能提升 # 3. ... 
- ztree点击加号+触发ajax请求
			之前做的时候一直是点击节点才触发ajax事件,配置如下:发现点击节点前面的“+”没有反应,后来发现,应该添加一个折叠的事件. onExpand:zTreeOnClick事件和onClick的一样. v ... 
- httprunner
			https://cn.httprunner.org/quickstart/ httprunner官方 https://testerhome.com/opensource_projects/httpru ... 
- Cocos Creator更改底层,点击节点获取路径
			Mac : 右键creator->显示包内容->Contents->Resources->engine->bin->cocos2d-js-for-preview.j ... 
