WinForms › Extended Label
Extended Label
.NET Framework 4.8.NET 6 / 8 / 10v2.0.0WinForms
A label for headings, captions and status panels that can draw a gradient background, a border, a drop shadow, and text turned on its side.
4public types
40public members
1namespaces
Assembly
| Assembly | Binarymission.WinForms.Controls.BinaryExtendedLabel.dll |
| Root namespace | Binarymission.WinForms.Controls.Containers |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
Overview
What it is for
Use it where a plain Label is too flat: a section heading on a settings page, a
caption tile on a dashboard ("Open orders: 42"), or a vertical title down the edge of a panel. It is
drawn entirely by the control, so the background, border, shadow and text can be styled
independently.
The parts
- Background – a gradient from
StartLinearGradientBackgroundColortoEndLinearGradientBackgroundColoratBackgroundGradientFloatAngle; give both the same colour for a solid fill.IsBackgroundTransparentshows the parent through instead. - Shadow – drawn below and to the right,
DropShadowMargindeep: soft and blurred by default (ShouldDrawSoftDropShadow), or a gradient block. - Border –
BorderColorinBorderDashStyle, its weight chosen byBorderDrawingStyle. - Text –
Textin the control'sControl.FontandControl.ForeColor, placed byTextAlignmentinsideControl.Padding, horizontal or vertical (Orientation,VerticalTextDirection). Line breaks in the text start new lines.
The shadow and the border are on by default, so a new label shows a black one-pixel border with
a soft grey shadow. Set ShouldDrawDropShadow and ShouldDrawBorder to
false for a flat caption. The label is left out of the tab order.
Getting started
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.Containers;
public class SalesDashboard : Form
{
public SalesDashboard()
{
Text = "Today's sales";
ClientSize = new Size(360, 260);
// A caption tile with a blue gradient and a soft shadow.
var openOrders = new ExtendedLabel
{
Text = "Open orders\n42",
Location = new Point(60, 20),
Size = new Size(200, 80),
Font = new Font("Segoe UI", 12f, FontStyle.Bold),
ForeColor = Color.White,
StartLinearGradientBackgroundColor = Color.SteelBlue,
EndLinearGradientBackgroundColor = Color.MidnightBlue,
BackgroundGradientFloatAngle = 90f,
TextAlignment = ContentAlignment.MiddleCenter,
BorderColor = Color.MidnightBlue,
DropShadowMargin = 5
};
// A vertical title down the left edge, with no shadow or border.
var sideTitle = new ExtendedLabel
{
Text = "Northern region",
Location = new Point(12, 20),
Size = new Size(220, 32),
ShouldDrawDropShadow = false,
ShouldDrawBorder = false,
Orientation = ExtendedLabel.DrawingOrientation.Vertical, // swaps Width and Height
VerticalTextDirection = ExtendedLabel.TextDirection.BottomTop
};
Controls.Add(openOrders);
Controls.Add(sideTitle);
}
}API reference
Binarymission.WinForms.Controls.Containers
class ExtendedLabel | A label for headings, captions and status panels that can draw a gradient background, a border, a drop shadow, and text turned on its side. |
enum BorderStyle | The weights of border an ExtendedLabel can draw. |
enum DrawingOrientation | Which way the text of an ExtendedLabel runs. |
enum TextDirection | Which way vertical text in an ExtendedLabel reads. |