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的更多相关文章

  1. 用Delphi画圆角Panel的方法(使用CreateRoundRectRgn创造区域,SetWindowRgn显示指定区域)

    用Delphi画圆角Panel的方法: procedure TForm1.Button5Click(Sender: TObject);var fhr :Thandle;beginfhr:=Create ...

  2. C# 用户控件之温度计

    本文以一个用户控件[User Control]实现温度计的小例子,简述用户控件的相关知识,以供学习分享使用,如有不足之处,还请指正. 概述 一般而言,用户控件[User Control],是在Visu ...

  3. C#用户自定义控件(含源代码)-透明文本框

    using System; using System.Collections; using System.ComponentModel; using System.Drawing; using Sys ...

  4. 【控件扩展】带圆角、边框、渐变的panel

    下载地址:  http://files.cnblogs.com/chengulv/custompanel_demo.zip using System; namespace LC.Fun { /// & ...

  5. Panel扩展 圆角边框,弧形边框

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...

  6. winfrom组件圆角

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

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

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

  8. jQuery Moblie 学习之page、button、theme、panel、listview、controlgroup、navbar等(一)

    1.jQTouch jQTouch与jQuery Moblie十分相似,也是一个jQuery插件,同样也支持HTML页面标签驱动,实现移动设备视图切换效果.不同的是它是专为WebKit内核的浏览器打造 ...

  9. Ext.Panel的主要功能

    介绍面板组件的主要配置项及经常用法,这些配置项及方法将在后面的演示样例中用到,能够把这部分内容作为兴许章节的铺垫,进行高速的浏览,Ext.Panel主要配置项目如表5-1所看到的. 表5-1  Ext ...

随机推荐

  1. 什么是lambda函数?有什么好处?

    lambda 函数是一个可以接收任意多个参数(包括可选参数)并且返回单个表达式值的匿名函数 好处:1.lambda 函数比较轻便,即用即删除,很适合需要完成一项功能,但是此功能只在此一处使用,连名字都 ...

  2. wordpress开发的一些积累

    wordpress 攒知识点 记录开发 wordpress 的一些技能点,以备不时之需 短代码 Shortcode 虽然很多插件都是提供,直接在代码中插入类似[Shortcode] 便可以生效,但是很 ...

  3. Springboot+Jedis+Ehcache整合

    项目结构概览: 1. 导包 <parent> <groupId>org.springframework.boot</groupId> <artifactId& ...

  4. mysql时间类型

    转自:http://www.cnblogs.com/Matrix54/archive/2012/05/01/2478158.html AVA中获取当前系统时间 一. 获取当前系统时间和日期并格式化输出 ...

  5. Chrome开发者工具详解(三)之浏览器调试完后如何清除所有的断点

  6. mysql的innodb 引擎 表锁与行锁

    innodb 引擎 行锁与表锁 行锁与表锁是基于索引来说的(且索引要生效) 不带索引 (表锁)要全表扫描 1. 执行select @@autocommit; 查看结果 0是不自动提交事务,1是自动提交 ...

  7. java web请求过程

    小技巧: 1.浏览器缓存 Ctrl+F5组合键刷新页面,浏览器会直接向目标URL发送请求,而不会使用浏览器缓存,并会在HTTP请求header中增加下面的请求头来告诉服务器不使用服务器缓存 发现在re ...

  8. 分布式FastDfs+nginx缓存高可用集群构建

    介绍: FastDFS:开源的高性能分布式文件系统:主要功能包括:文件存储,文件同步和文件访问,以及高容量和负载平衡 FastDFS:角色:跟踪服务器(Tracker Server).存储服务器(St ...

  9. Python中numpy的应用

    #创建ndarray import numpy as np nd = np.array([2,4,6,'])#numpy中默认ndarray的所有元素的数据类型是相同,如果数据的类型不同,会统一为统一 ...

  10. git log 详解 以及代码量统计

    https://git-scm.com/book/zh/v1/Git-%E5%9F%BA%E7%A1%80-%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E5%8E%86% ...