Source
Using System;
Using System.Windows.Forms;
Using System.Drawing;
Using System.Drawing.Drawing2D;
Using System.ComponentModel;
Namespace Wzsbmain
{
<summary>
Summary description for Labelgradient.
</summary>
public class WzsbmainLabel:System.Windows.Forms.Label
{
#region Implementtation member Fields
protected Color gradientcolorone = Color.White;
protected Color gradientcolortwo = Color.Blue;
protected LinearGradientMode LGM = lineargradientmode.forwarddiagonal;
protected Border3DStyle B3dstyle = Border3dstyle.bump;
#endregion
#region Gradientcolorone Properties
[
DefaultValue (typeof (Color), "white"),
Description ("The gradient color."),
Category ("appearance"),
]
Gradientcolorone Properties
Public Color Gradientcolorone
{
Get
{
return gradientcolorone;
}
Set
{
Gradientcolorone = value;
Invalidate ();
}
}
#endregion
#region Gradientcolortwo Properties
[
DefaultValue (typeof (Color), "Blue"),
Description ("The second gradient color."),
Category ("appearance"),
]
Gradientcolortwo Properties
Public Color Gradientcolortwo
{
Get
{
return gradientcolortwo;
}
Set
{
Gradientcolortwo = value;
Invalidate ();
}
}
#endregion
#region LinearGradientMode Properties
LinearGradientMode Properties
[
DefaultValue (typeof (LinearGradientMode), "forwarddiagonal"),
Description ("Gradient Mode"),
Category ("appearance"),
]
Public LinearGradientMode Gradientmode
{
Get
{
return LGM;
}
Set
{
LGM = value;
Invalidate ();
}
}
#endregion
#region Border3DStyle Properties
Border3DStyle Properties
[
DefaultValue (typeof (Border3DStyle), "Bump"),
Description ("BorderStyle"),
Category ("appearance"),
]
Hide BorderStyle inherited from the base class
New public Border3DStyle BorderStyle
{
Get
{
return b3dstyle;
}
Set
{
B3dstyle = value;
Invalidate ();
}
}
#endregion
#region removed Properties
Remove BackColor Property
[
Browsable (False),
Editorbrowsable (Editorbrowsablestate.never)
]
public override System.Drawing.Color BackColor
{
Get
{
return new System.Drawing.Color ();
}
set {;}
}
#endregion
protected override void OnPaint (System.Windows.Forms.PaintEventArgs e)
// {
Graphics gfx = e.graphics;
Border3DStyle B3dstyle = border3dstyle.bump;
Border3dside b3dside = Border3dside.all;
//
Rectangle rect = new Rectangle (0,0,this. Width,this. Height);
//
Dispose of Brush Resources
using (LinearGradientBrush LGB = new LinearGradientBrush (rect, GRADIENTCOLORONE,GRADIENTCOLORTWO,LGM))
Gfx. FillRectangle (Lgb,rect);
//
3d border
Controlpaint.drawborder3d (Gfx,rect,b3dstyle,b3dside);
//
//
Call the OnPaint method of the base class
Base. OnPaint (e);
//
// }
protected override void OnPaintBackground (System.Windows.Forms.PaintEventArgs pevent)
{
Graphics GFX = pevent. Graphics;
Rectangle rect = new Rectangle (0,0,this. Width,this. Height);
Dispose of Brush Resources
using (LinearGradientBrush LGB = new LinearGradientBrush (rect, GRADIENTCOLORONE,GRADIENTCOLORTWO,LGM))
Gfx. FillRectangle (Lgb,rect);
Controlpaint.drawborder3d (Gfx,rect,b3dstyle);
}
}
}