Introduction
The Office2007 style button is very easy to use. Only DragDrop ToolBox.
Using the Code
internal void DrawControl(Graphics e)
{
recBounds = this.ClientRectangle;
Rectangle m_BrushSize=new Rectangle(0, 0,
this.Width , this.Height / 2);
for(int i=0;i<=40;i++)
{
LinearGradientBrush myLinearGradientBrush1 =
new System.Drawing.Drawing2D.LinearGradientBrush
(m_BrushSize, Color.FromArgb(i,220,252,255),
Color.FromArgb(i,125,195,236),
90);
LinearGradientBrush myLinearGradientBrush=
new LinearGradientBrush(m_BrushSize, Color.FromArgb(i,93,174,221),
Color.FromArgb(i,177,252,255),
-90);
myLinearGradientBrush.WrapMode =System.Drawing.Drawing2D.WrapMode.TileFlipXY;
myLinearGradientBrush1.WrapMode=System.Drawing.Drawing2D.WrapMode.TileFlipXY;
e.FillRectangle(myLinearGradientBrush,1, this.Height/2,
this.Width-2 , this.Height / 2-1);
e.FillRectangle(myLinearGradientBrush1,1, 1,
this.Width-2 , this.Height / 2);
Brush brsBorder=new SolidBrush(Color.FromArgb(121,157,182));
Pen pnsBorder=new Pen(brsBorder);
Brush brsDot=new SolidBrush(Color.FromArgb(179,201,214));
Pen pnsDot=new Pen(brsDot);
e.DrawRectangle(Pens.White,this.ClientRectangle.X+1,
this.ClientRectangle.Y+1,this.ClientRectangle.Width-3,
this.ClientRectangle.Height-3);
e.DrawLine(pnsDot,this.ClientRectangle.X,this.ClientRectangle.Y+1,
this.ClientRectangle.X+1,this.ClientRectangle.Y+1);
e.DrawLine(pnsDot,this.ClientRectangle.X,this.ClientRectangle.Bottom-2,
this.ClientRectangle.X+1,this.ClientRectangle.Bottom-2);
e.DrawLine(pnsDot,this.ClientRectangle.Right-1,this.ClientRectangle.Bottom-2,
this.ClientRectangle.Right-2,this.ClientRectangle.Bottom-2);
e.DrawLine(pnsDot,this.ClientRectangle.Right-1,this.ClientRectangle.Y+1,
this.ClientRectangle.Right-2,this.ClientRectangle.Y+1);
e.DrawLine(pnsBorder,this.ClientRectangle.X+1,this.ClientRectangle.Y,
this.ClientRectangle.Right-2,this.ClientRectangle.Y);
e.DrawLine(pnsBorder,this.ClientRectangle.X,this.ClientRectangle.Y+1,
this.ClientRectangle.X,this.ClientRectangle.Bottom-2);
e.DrawLine(pnsBorder,this.ClientRectangle.X+1,this.ClientRectangle.Bottom-1,
this.ClientRectangle.Right-2,this.ClientRectangle.Bottom-1);
e.DrawLine(pnsBorder,this.ClientRectangle.Right-1,this.ClientRectangle.Y+1,
this.ClientRectangle.Right-1,this.ClientRectangle.Bottom-2);
OnDrawTextAndImage(e);
myLinearGradientBrush.Dispose();
myLinearGradientBrush1.Dispose();
brsBorder.Dispose();
brsDot.Dispose();
pnsBorder.Dispose();
pnsDot.Dispose();
}
}
History
- 10th April, 2007: Initial post