Class GradientLabel
The GradientLabel class provides a way to create fancy and appealing labels in all your forms.
Inheritance
Namespace: Syncfusion.Windows.Forms.Tools
Assembly: Syncfusion.Tools.Windows.dll
Syntax
public class GradientLabel : Label, IThemeProvider, IVisualStyle
Remarks
The GradientLabel class is fully compatible with the Windows Forms System.Windows.Forms.Label that it derives from. The GradientLabel class gets most of its uniqueness from the BrushInfo class that is used for the BackgroundColor property. The look and feel of the GradientLabel is almost completely configurable through the BackgroundColor property. The System.Windows.Forms.Border3DStyle is another property that can specify the look and feel of the GradientLabel.
Examples
// InitializeComponent
// Create the Gradient Label
this.gradientLabel1 = new GradientLabel();
// Set formatting properties
this.gradientLabel1.Text = "Essential Suite Gradient Label";
this.gradientLabel1.BackgroundColor = new BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.SystemColors.Highlight, System.Drawing.SystemColors.HighlightText);
this.gradientLabel1.BorderStyle = Border3DStyle.Etched;
this.gradientLabel1.Font = new Font("Microsoft Sans Serif", 14.25F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.gradientLabel1.Location = new Point(24, 16);
this.gradientLabel1.Name = "gradientLabel1";
this.gradientLabel1.Size = new Size(440, 56);
this.gradientLabel1.TextAlign = ContentAlignment.MiddleCenter;
// Add the GradientLabel control to the form
this.Controls.Add(this.gradientLabel1);
' InitializeComponent
' Create the GradientLabel control.
Me.gradientLabel1 = New GradientLabel()
' Set formatting properties
Me.gradientLabel1.Text = "Essential Suite Gradient Label"
Me.gradientLabel1.BackgroundColor = New BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.SystemColors.Highlight, System.Drawing.SystemColors.HighlightText)
Me.gradientLabel1.BorderStyle = Border3DStyle.Etched
Me.gradientLabel1.Font = New Font("Microsoft Sans Serif", 14.25!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.gradientLabel1.Location = New Point(24, 16)
Me.gradientLabel1.Name = "gradientLabel1"
Me.gradientLabel1.Size = New Size(440, 56)
Me.gradientLabel1.TextAlign = ContentAlignment.MiddleCenter
' Add the GradientLabel control to the form
Me.Controls.Add(Me.gradientLabel1)
Constructors
GradientLabel()
Declaration
public GradientLabel()
Properties
BackColor
Gets or sets the BackColor. (overridden property)
Declaration
public override Color BackColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
BackgroundColor
Gets or sets the background color and other styles.
Declaration
public BrushInfo BackgroundColor { get; set; }
Property Value
Type |
---|
BrushInfo |
Remarks
This property is the most important attribute of the GradientLabel class. The BrushInfo class that is used by this property is a very extensive implementation for custom painting. You can configure the different look and feel you want to give your GradientLabel by changing this value.
BeforeTouchSize
Gets/Sets Control size before touch enabled
Declaration
public Size BeforeTouchSize { get; set; }
Property Value
Type |
---|
System.Drawing.Size |
BorderAppearance
Gets or sets a value indicating the border appearance of the gradient label.
Declaration
public BorderStyle BorderAppearance { get; set; }
Property Value
Type |
---|
System.Windows.Forms.BorderStyle |
BorderColor
Gets or sets a value indicating the border color of the gradient label. Can be set only in case if BorderAppearance is FixedSingle.
Declaration
public Color BorderColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
BorderSides
Gets or sets the sides of the label that has borders drawn.
Declaration
public Border3DSide BorderSides { get; set; }
Property Value
Type |
---|
System.Windows.Forms.Border3DSide |
Remarks
This property uses the System.Windows.Forms.Border3DSide enumeration. Setting the value to System.Windows.Forms.Border3DSide.All shows borders on all sides.
BorderStyle
Gets or sets the 3D border style for the GradientLabel.
Declaration
public Border3DStyle BorderStyle { get; set; }
Property Value
Type |
---|
System.Windows.Forms.Border3DStyle |
Remarks
The GradientLabel replaces the default BorderStyle provided for System.Windows.Forms.Label classes with the Border3DStyle type in this property. This property uses the System.Windows.Forms.Border3DStyle enumeration. Setting the value to System.Windows.Forms.Border3DStyle.Adjust shows no border.
CanApplyTheme
Gets or sets a value indicating whether a SkinManager theme style has been applied to the control.
Declaration
public bool CanApplyTheme { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
CanOverrideStyle
Gets or sets a value indicating whether control elements styles can be overridden by theme style settings.
Declaration
public bool CanOverrideStyle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Default value is false. |
Remarks
By default, the control's element styles will not be overridden by theme style settings if the style is set in sample level. If this property is enabled, element style will be overridden by theme style settings event if it is set in sample level. This property should be enabled or disabled before calling the ThemeName property of the control.
DrawActiveWhenDisabled
Gets or sets a value indicating whether the text should be drawn active when the control is disabled.
Declaration
public bool DrawActiveWhenDisabled { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableTouchMode
Gets or sets value to enable or disable the Touchmode to the controls.
Declaration
public bool EnableTouchMode { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Scale factor will be updated automatically if scalefactor is equal to 1
Font
Overrides the base font property.
Declaration
public override Font Font { get; set; }
Property Value
Type |
---|
System.Drawing.Font |
IsVisualStyleEnabled
Gets a value indicating whether the visual style based theme is applied to the control. This also indicates whether the theme files are referred from external assemblies or not.
Declaration
public bool IsVisualStyleEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Return true, if the visual style based theme is applied to control. Otherwise returns false. |
ThemeName
Gets or sets the theme name of the GradientLabel control.
Declaration
public string ThemeName { get; set; }
Property Value
Type |
---|
System.String |
ThemeStyle
Gets or sets the GradientLabelVisualStyle value used to customize the appearance of the CheckBoxAdv.
Declaration
public GradientLabelVisualStyle ThemeStyle { get; set; }
Property Value
Type |
---|
GradientLabelVisualStyle |
Remarks
This ThemeStyle settings will be applied only when the VisualStyleBased theme has been applied to the control.
Methods
ApplyScaleToControl(Single)
Scale the control based on the scale factor passed in the argument.
Declaration
public void ApplyScaleToControl(float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scaleFactor | value to scale the factor based upon. |
DrawBackground(Graphics)
Draws the background. This is invoked by the OnPaintBackground(PaintEventArgs) override.
Declaration
protected virtual void DrawBackground(Graphics g)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The graphics object that the background is to be drawn on. |
Remarks
You can override this virtual function to provide your own drawing methods.
DrawBorder(Graphics)
Draws the 3D border for the GradientLabel. This is invoked by the OnPaintBackground(PaintEventArgs) override.
Declaration
protected virtual void DrawBorder(Graphics g)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The graphics object that the background is to be drawn on. |
Remarks
The 3D border specified in the System.Windows.Forms.Border3DStyle property is drawn in this method on the provided System.Drawing.Graphics object.
GetActiveThemeName()
Gets the active theme name of the GradientLabel control.
Declaration
public string GetActiveThemeName()
Returns
Type | Description |
---|---|
System.String | Returns the active theme name. |
OnFontChanged(EventArgs)
Font changed
Declaration
protected override void OnFontChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnPaint(PaintEventArgs)
Declaration
protected override void OnPaint(PaintEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.PaintEventArgs | e |
OnPaintBackground(PaintEventArgs)
Overrides the OnPainBackground method of the System.Windows.Forms.Label class.
Declaration
protected override void OnPaintBackground(PaintEventArgs pe)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.PaintEventArgs | pe | The event args value for the event. |
Remarks
This method is overriden to paint the background of the GradientLabel so that the text drawn by the default painting routines will not be affected. The 3D border specified through the System.Windows.Forms.Border3DStyle is also painted through this method.
OnSizeChanged(EventArgs)
Declaration
protected override void OnSizeChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
Events
ThemeNameChanged
Occurs when theme name of the GradientLabel has changed.
Declaration
public event ThemeChangedEventHandler ThemeNameChanged
Event Type
Type |
---|
ThemeChangedEventHandler |
Explicit Interface Implementations
IVisualStyle.VisualTheme
Declaration
string IVisualStyle.VisualTheme { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.BaseThemeName
Gets or sets the BaseTheme name of the theme
Declaration
string IThemeProvider.BaseThemeName { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.ControlName
Gets the name of the control.
Declaration
string IThemeProvider.ControlName { get; }
Returns
Type |
---|
System.String |