




已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
c#下重寫B(tài)UTTON控件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: 在此處添加構(gòu)造函數(shù)邏輯/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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《學(xué)前兒童藝術(shù)教育與活動(dòng)指導(dǎo)》電子教案-11 學(xué)前兒童美術(shù)教育評(píng)價(jià)
- 上海市華東政法大學(xué)附屬中學(xué)2021-2022學(xué)年高一下學(xué)期期中歷史 無答案
- 四川省合江縣馬街中學(xué)2023-2024學(xué)年高三上學(xué)期1月期末英語試題 含解析
- 2023屆四川省攀枝花市東區(qū)攀枝花市三中高三校二模理綜生物試題 含解析
- 2025-2030中國移液管配件行業(yè)市場發(fā)展趨勢(shì)與前景展望戰(zhàn)略研究報(bào)告
- 山東省威海市乳山市銀灘高級(jí)中學(xué)2024-2025學(xué)年高一下學(xué)期4月月考地理試題(含答案)
- 煤氣中毒治療用藥指導(dǎo)
- 大學(xué)生職業(yè)規(guī)劃大賽《法語專業(yè)》生涯發(fā)展展示
- 高空作業(yè)人員安全帶佩戴規(guī)定
- 2025年中國鉭金屬化合物數(shù)據(jù)監(jiān)測(cè)報(bào)告
- 高考標(biāo)準(zhǔn)化考場建設(shè)的方案
- 乳腺癌NCCN指南中文版2022.v2
- GB/T 38942-2020壓力管道規(guī)范公用管道
- 家居建材全屋定制店面運(yùn)營管理細(xì)則規(guī)定
- GB/T 27924-2011工業(yè)貨架規(guī)格尺寸與額定荷載
- 大班語言《他們看見了一只貓》課件
- 畢業(yè)論文-電力變壓器設(shè)計(jì)
- 消毒產(chǎn)品進(jìn)貨檢查驗(yàn)收制度
- 單叉固定式液壓升降臺(tái)設(shè)計(jì)
- 《美國消費(fèi)品安全改進(jìn)法》的普通合格證書、紡織品服裝類產(chǎn)
- GB∕T 40740-2021 堆焊工藝評(píng)定試驗(yàn)
評(píng)論
0/150
提交評(píng)論