圆角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 ...
随机推荐
- [LeetCode] 212. 单词搜索 II
题目链接:https://leetcode-cn.com/problems/word-search-ii/ 题目描述: 给定一个二维网格 board 和一个字典中的单词列表 words,找出所有同时在 ...
- python常量 (最全常量解析)
常量 一.常量 变量是变化的量,常量则是不变的量.python中没有使用语法强制定义常量,也就是说,python中定义常量本质上就是变量.如果非要定义常量,变量名必须全大写. AGE_OF_NICK ...
- NoSQL特点
- linux下装python3以及pip3
1.wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz 2.tar zxvf Python-3.6.0.tgz 3.cd Pyt ...
- 通过实例简介python使用ctypes模块调用C语言动态库
看介绍python语言时,说它是胶水语言,可以调用其他语言.通过使用ctypes模块就可以调用C语言的动态库.下面先放上官方文档和几个比较好的博文. 1.官方文档:http://python.net/ ...
- Desert King(01分数规划问题)(最优斜率生成树)
Desert King Time Limit: 3000MS Memory Limit: 65536K Total Submissions:33847 Accepted: 9208 Descr ...
- 值不能为null.参数名: viewInfo,如何解决
有蓝队网络服务器租用客户反映在一台服务器上使用数据库管理工具时弹出了如下错误 :值不能为null.参数名: viewInfo (Microsoft.SqlServer.Management.SqlSt ...
- Codeforces 907 矩阵编号不相邻构造 团操作状压DFS
A. #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #de ...
- GUI学习之十四——QKeySequenceEdit学习总结
我们在前面总结了3种文本输入控件,这里有一种新的:QKeySequenceEdit,用作对快捷键的采集.结合其内部的API可以实现对自定义快捷键的设置.这节内容大致看一下就好了,我也不知道实际作用有哪 ...
- index 索引
1.创建表 drop table if exists kg_fk_user;create table kg_fk_user(id int,name string)row format delimite ...