圆角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 ...
随机推荐
- JProfiler> ERROR: Invalid license key. Aborting.
用IDEA+Tomcat的方式打开JProfiler,出现错误 1,Event Log 出错 16:10 Application Server was not connected before run ...
- unsolved question's solution
因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打code了 $luogu:$ P1973 [NOI2011]Noi嘉年华: 时间离散化,预处理一个区间$[l,r]$内的最多活动个数$in[l] ...
- Android 在同一个手机上安装多个相同的apk,便于调试
Android studio 在同一个手机上安装多个相同的apk 原文地址:http://yj.itrydo.com/posts/iKJryXL9zkfSGRTZk 先看效果: 1.在我使用ecsli ...
- .net 正则表达式
string RegStr = @"^[0-9]*[1-9][0-9]*$"; if (Regex.IsMatch("待验证的字符串", RegStr)) { ...
- 不启动或进入虚拟机,查看 KVM 虚拟机中的网卡信息
#!bin/bash#作者:liusingbon#功能:#脚本使用工具guestmount,可以将虚拟机的磁盘系统挂载到真实机文件系统中#Centos7.2中安装libguestfs-tools-c, ...
- python socket--TCP解决粘包的方法
1.为什么会出现粘包?? 让我们基于tcp先制作一个远程执行命令的程序(1:执行错误命令 2:执行ls 3:执行ifconfig) 注意注意注意: res=subprocess.Popen(cmd.d ...
- ubuntu进入纯命令行
启动按shfit 然后光标在第一行按e 倒数第二行末尾添加quiet splash $vt_handoff 3 然后按CTRL+X或F10引导系统,启动之后就是命令行模式了
- mepg
MPEG(Moving Picture Experts Group,动态图像专家组)
- expect实现远程主机自动执行命令脚本
2014年第一个脚本,哈哈!!! expect实现远程主机自动执行命令脚本: #!/usr/bin/expect -- if { [llength $argv] < 4 } { puts &qu ...
- App开发工具
软件下载: 链接:https://pan.baidu.com/s/1yaAko1svHW3v3kdn6mSgxQ提取码:rrcd 参考文档地址: http://dev.dcloud.net.cn/mu ...