基本信息
源码名称:自定义水晶按钮控件
源码大小:7.72M
文件格式:.rar
开发语言:C#
更新时间:2021-01-07
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
自定义水晶按钮控件
private void TransparencyButton_Paint(object sender, PaintEventArgs e) { this.BackColor = Color.Transparent;//使当前控件透明 sm = e.Graphics.SmoothingMode;//设置呈现质量 Color shineColor = Color.Black; Rectangle rect2 = new Rectangle(0, 0, this.Width, this.Height);//设置绘制按钮的矩形区域 Rectangle rect1 = new Rectangle(0, this.Height / 2, this.Width, this.Height / 2);//设置绘制按钮下半部的矩形区域 if (this.CTransparence == 0)//如果按钮的透明度为0 { CobOblongDown(rect2, e.Graphics);//绘制按扭的背景 CobOblong(rect2, e.Graphics, this.ShineColor);//绘制按扭的背景 } else { if (this.CTransparence > 0)//如果按钮的透明度不为0 { CobOblongDown(rect2, e.Graphics);//绘制按扭的背景 for (int i = 0; i < CTransparence; i ) { CobOblong(rect2, e.Graphics, this.ShineColor);//绘制按扭的背景颜色 } } } int tem_n = (int)(this.CTransparence / 3);//获取一个值,用于设置下半部按钮的颜色深度 if (tem_n == 0)//如果为0 CobAjar(rect1, e.Graphics, this.ShineColor);//绘制按扭的下半部背景 else { if (tem_n > 0)//如果不为0 { for (int i = 0; i < tem_n; i )//加深下部按钮的颜色 { CobAjar(rect1, e.Graphics, this.ShineColor);//绘制按扭的下半部背景颜色 } } } CobOblong(rect2, e.Graphics, this.UndersideShine);//设置下半部按钮的光泽度 if (pub_ButtonClick == false)//判断按钮是否按下(false为按下) { CobOblongDown(rect2, e.Graphics);//绘制按扭的背景 } if (this.NText.Length > 0)//如果Text属性中有值 ProtractText(e.Graphics);//绘制透明按钮的文本信息 } private void TransparencyButton_SizeChanged(object sender, EventArgs e) { Invalidate();//对控件进行重绘 } private void TransparencyButton_MouseDown(object sender, MouseEventArgs e) { pub_ButtonClick = false;//按下按钮 Invalidate();//对控件进行重绘 } private void TransparencyButton_MouseUp(object sender, MouseEventArgs e) { pub_ButtonClick = true;//松开按钮 Invalidate();//对控件进行重绘 }