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 first 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 after use
// 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 after use
using (lineargradientbrush lgb = new lineargradientbrush(rect, gradientcolorone,gradientcolortwo,lgm))
gfx.fillrectangle(lgb,rect);
controlpaint.drawborder3d(gfx,rect,b3dstyle);
}
}
}
新闻热点
疑难解答