XPButton.cs代码
using System;
using System.Windows;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows .Forms ;
namespace XPCtrl
{
/// <summary>
/// XPButton 的摘要说明。
/// </summary>
public class XPButton:System.Windows.Forms.Button
{
private 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 Point[8];
points[0].X=offsetwidth;
points[0].Y=0;
points[1].X=this.Width-offsetwidth;
points[1].Y=0;
points[2].X=this.Width;
points[2].Y=offsetwidth;
points[3].X=this.Width;
points[3].Y=this.Height-offsetwidth;
points[4].X=this.Width-offsetwidth;
points[4].Y=this.Height;
points[5].X=offsetwidth;
points[5].Y=this.Height;
points[6].X=0;
points[6].Y=this.Height-offsetwidth;
points[7].X=0;
points[7].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 Point[8];
points1[0].X=offsetwidth1;
points1[0].Y=2;
points1[1].X=this.Width-offsetwidth1;
points1[1].Y=2;
points1[2].X=this.Width-1;
points1[2].Y=off