Using system;
Using system.collections;
Using system.componentmodel;
Using system.drawing;
Using system.drawing.drawing2d;
Using system.windows.forms;
Namespace UPLibrary.upControls
{
///
// / Can display Lable of colored background colors
/// summary>
Public Class Uplabel: System.Windows.Forms.label
{
///
/// The required designer variable.
/// summary>
Private system.componentmodel.Container Components = NULL;
Private color startcolor = color.wheat;
PRIVATE color endcolor = color.limegreen;
Private brush basebackground = null;
PRIVATE BOOL ShowGradient = True;
Private float mangle = 75;
Private bool _showtext;
Public Uplabel ()
{
InitializationComponent ();
}
///
/// Clean all the resources being used.
/// summary>
Protected Override Void Dispose (Bool Disposing)
{
IF (Disposing)
{
IF (Components! = NULL)
{
Components.dispose ();
}
}
Base.dispose (Disposing);
}
#REGION component designer generated code
///
/// Designer supports the required method - do not use the code editor
// / Modify the content of this method.
/// summary>
Private vidinitiRizeComponent ()
{
//
// UPLabel
//
This.Size = new system.drawing.size (144, 21);
}
#ndregion
Protected Override Void OnPainTBackground (Painteventargs E)
{
LINEARGRADIENTBRUSH LBS;
Base.onpaintbackground;
IF (this.disposing) return;
IF (basebackground == NULL)
{
IF (showgradient)
{
LBS = New lineargradientbrush (
ClientRectangle,
StartColor,
EndColor,
Angle);
Basebackground = lbs;
}
Else IF (BackgroundImage! = NULL)
{
Basebackground = new texturebrush (BackgroundImage);
}
Else
{
Basebackground = new solidbrush; backcolor
}
}
E.Graphics.FillRectangle (BaseBackground, ClientRectangle);
E.Graphics.flush ();
}
[
Category ("Gradient"), DEFAULTVALUE (TRUE),
Description ("indicates whether text is displayed.")
]
Public Bool ShowText
{
get
{
Return_ShowText;
}
set
{
IF (value! = _showtext)
{
_ShowText = Value;
IF (Basebackground! = NULL)
{
Basebackground.dispose ();
Basebackground = NULL;
}
Invalidate ();
}
}
}
[
Category ("Gradient"),
DefaultValue (TRUE),
Description ("indicates whether the background should display color gradient.")
]
Public Bool ShowGradient
{
get
{
Return ShowGradient;
}
set
{
IF (Value! = showgradient)
{
Showgradient = value;
IF (Basebackground! = NULL)
{
Basebackground.dispose ();
Basebackground = NULL;
}
Invalidate ();
}
}
}
[
Category ("Gradient"),
Description ("Specify the angle of gradient")
]
Public Float Angle
{
get
{
Return mangle;
}
set
{
Mangle = Value;
IF (basebackground! = null&& showgradient)
{
Basebackground.dispose ();
Basebackground = NULL;
}
Invalidate ();
}
}
[
Category ("Gradient"),
Description ("Specifies the start color")
]
Public Color StartColor
{
get
{
Return Startcolor;
}
set
{
STARTCOLOR = Value;
IF (basebackground! = null&& showgradient)
{
Basebackground.dispose ();
Basebackground = NULL;
}
Invalidate ();
}
}
[
Category ("Gradient"),
Description ("Designation End Color")
]
Public Color EndColor
{
get
{
Return Endcolor;
}
set
{
EndColor = Value;
IF (basebackground! = null&& showgradient)
{
Basebackground.dispose ();
Basebackground = NULL;
}
Invalidate ();
}
}
[Description ("Sequence (persistence)" "" "" "" "))
Public Bool ShouldSerializstartColor ()
{
Return! (STARTCOLOR == color.wheat);
}
Public Bool ShouldSerializeEndColor ()
{
Return! (endcolor == color.limegreen);
Protected Override Void OnBackColorChanged (Eventargs E)
{
Base.onbackColorChanged (e);
IF ((Basebackground! = null) && (! showgradient))
{
Basebackground.dispose ();
Basebackground = NULL;
}
}
Protected Override Void OnTextChanged (Eventargs E)
{
Base.OntextChanged (e);
IF ((Basebackground! = null) && (! showgradient))
{
Basebackground.dispose ();
Basebackground = NULL;
}
}
Protected Override Void OnBackgroundImageChanged (Eventargs E)
{
Base.onbackgroundImageChanged (e);
IF ((Basebackground! = null) && (! showgradient))
{
Basebackground.dispose ();
Basebackground = NULL;
}
}
Protected Override Void OnResize (Eventargs E)
{
Base.onResize (e);
IF (Basebackground! = NULL)
{
Basebackground.dispose ();
Basebackground = NULL;
}
}
}
}