




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
c#下重写BUTTON控件XPButton.cs代码using System;using System.Windows;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows .Forms ;namespace XPCtrl/ / XPButton 的摘要说明。/ public class XPButton:System.Windows.Forms.Buttonprivate bool mouseover=false;public XPButton()/ TODO: 在此处添加构造函数逻辑/this.Cursor = System.Windows.Forms.Cursors.Hand;protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)/base.OnPaint (e);/System.Drawing.Graphics pp=this.CreateGraphics();/e.Graphics.Clear(Color.Transparent);/e.Graphics.DrawEllipse(new System.Drawing.Pen(System.Drawing.Color.WhiteSmoke,5),0,0,this.Width,this.Height);/System.Drawing.SolidBrush dd=new SolidBrush(System.Drawing.Color.WhiteSmoke);/e.Graphics.FillEllipse(dd,0,0,this.Width,this.Height);/ (this.BackColor.ToString ()Color c5 = Color.FromArgb(255,255,255);Color c2 = Color.FromArgb(192,192,192);if(mouseover)c5=Color.FromArgb(245,245,245);/c2=Color.FromArgb(192,192,192);c2=Color.FromArgb(180,175,190);Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c5, c2, LinearGradientMode.Vertical);/System.Drawing.Region=new Region(int offsetwidth=this.Width/50;Point points=new Point8;points0.X=offsetwidth;points0.Y=0;points1.X=this.Width-offsetwidth;points1.Y=0;points2.X=this.Width;points2.Y=offsetwidth;points3.X=this.Width;points3.Y=this.Height-offsetwidth;points4.X=this.Width-offsetwidth;points4.Y=this.Height;points5.X=offsetwidth;points5.Y=this.Height;points6.X=0;points6.Y=this.Height-offsetwidth;points7.X=0;points7.Y=offsetwidth;/e.Graphics.FillRectangle (b, ClientRectangle);e.Graphics.FillPolygon(b,points,FillMode.Winding);if(this.Focused)int offsetwidth1=(this.Width-5)/50+2;Point points1=new Point8;points10.X=offsetwidth1;points10.Y=2;points11.X=this.Width-offsetwidth1;points11.Y=2;points12.X=this.Width-1;points12.Y=offsetwidth1;points13.X=this.Width-1;points13.Y=this.Height-offsetwidth1;points14.X=this.Width-offsetwidth1;points14.Y=this.Height-1;points15.X=1;points15.Y=this.Height-1;points16.X=2;points16.Y=this.Height-offsetwidth1;points17.X=2;points17.Y=offsetwidth1;/e.Graphics.DrawPolygon(new Pen(Color.Yellow,2),points1);Pen p=new Pen(Color.Orange,2);Pen p1=new Pen(Color.Wheat,2);/p.DashStyle=DashStyle.DashDot;e.Graphics.DrawLine(p1,points10,points11);e.Graphics.DrawLine(p,points11,points12);e.Graphics.DrawLine(p,points12,points13);e.Graphics.DrawLine(p,points13,points14);e.Graphics.DrawLine(p,points14,points15);e.Graphics.DrawLine(p,points15,points16);e.Graphics.DrawLine(p1,points16,points17);e.Graphics.DrawLine(p1,points17,points10);e.Graphics.DrawPolygon(new Pen(Color.DarkBlue,2),points);/e.Graphics.DrawLine(new Pen(Color.DarkBlue,2),new Point(0,0),new Point(this.Width,0);/e.Graphics.DrawLine(new Pen(Color.DarkBlue,2),new Point(0,0),new Point(0,this.Height);/e.Graphics.DrawLine(new Pen(Color.DarkBlue,2),new Point(this.Width,this.Height),new Point(this.Width,0);/e.Graphics.DrawLine(new Pen(Color.DarkBlue,2),new Point(this.Width,this.Height),new Point(0,this.Height);StringFormat drawFormat = new StringFormat();drawFormat.FormatFlags = StringFormatFlags.DisplayFormatControl;drawFormat.LineAlignment=StringAlignment.Center;drawFormat.Alignment=System.Drawing.StringAlignment.Center;e.Graphics.DrawString(this.Text,this.Font,new LinearGradientBrush(this.ClientRectangle,Color.Black,Color.Black,LinearGradientMode.Vertical),this.ClientRectangle,drawFormat);b.Dispose();protected override void OnLeave(EventArgs e)base.OnLeave (e);/protected override void OnMouseHover(EventArgs e)/mouseover=true;/this.Invalidate(false);/base.OnMouseHover (e);/protected override void OnMouseEnter(EventArgs e)mouseover=true;this.Invalidate(false);base.OnMouseEnter (e);protected override void OnNotifyMessage(System.Windows.Forms.Message m)base.OnNotifyMessage (m);protected override void OnMouseLeave(EventArgs e)mouseover=false;this.Invalidate(false);base.OnMouseLeave (e);private void DrawButton( System.Drawing.Graphics g)protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)/Color c5 = Color.FromArgb/(255,255,255);/Color c2 = Color.FromArgb/(192,192,192);/if(mouseover)/c5=Color.FromArgb(245,245,245);/c2=Color.FromArgb(192,192,192);/c2=Color.FromArgb(180,175,190);/Brush b = new System.Drawing.Drawing2D.LinearGradientBrush/(ClientRectangle, c5, c2, LinearGradientMode.Vertical);/pevent.Graphics .DrawRectangle(new Pen(Color.Transparent,2),this.C
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 甘肃xx新建光伏发电项目实施方案
- 工程项目市场竞争分析模型试题及答案
- 2025年医美消费市场动态分析报告:行业规范与发展策略优化
- 手术火灾应急预案(3篇)
- 2025年农村电商物流配送体系冷链物流发展建议报告
- 2025年生态修复工程中生态系统服务功能评估与生态系统服务供需匹配报告
- 2025年工程经济复习经典试题及答案
- 2025年药物研发与生产绿色生产技术市场分析报告
- 深度剖析公共关系的试题及答案
- 2025年工程项目管理战略思维试题及答案
- 中建中建滑模施工方案范本
- 【MOOC】颈肩腰腿痛中医防治-暨南大学 中国大学慕课MOOC答案
- 《法国师范教育》课件
- 安全法规-终结性考试-国开(SC)-参考资料
- 公司用工协议书简单范本(2篇)
- 第三单元《增强法治意识》测试卷-高二思想政治课《职业道德与法治》附答案
- 教育革新:2024版《认识交通标志》课件
- (高清版)DB4202∕T 39-2024 城市桥梁与隧道运行监测技术规范
- 数据分析师历年考试真题试题库(含答案)
- 住宅小区园林景观绿化工程施工组织设计方案
- 物质的量说课
评论
0/150
提交评论