c#下重寫B(tài)UTTON控件.doc_第1頁(yè)
c#下重寫B(tài)UTTON控件.doc_第2頁(yè)
c#下重寫B(tài)UTTON控件.doc_第3頁(yè)
c#下重寫B(tài)UTTON控件.doc_第4頁(yè)
c#下重寫B(tài)UTTON控件.doc_第5頁(yè)
已閱讀5頁(yè),還剩3頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

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. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論