BeepAdvancedButton
Advanced button control with 30+ pluggable style painters, shape customization, semantic intents, rich animations, and split-area interaction
Table of Contents
Overview
BeepAdvancedButton is the flagship button control in the Beep WinForms library. It supports 30+ distinct visual styles through a pluggable painter system, each implemented as a separate class extending BaseButtonPainter. The control is organized as a partial class split across two files, with supporting enumerations, models, helpers, and painter classes in dedicated subdirectories.
| Namespace | TheTechIdea.Beep.Winform.Controls.Buttons.BeepAdvancedButton |
| Assembly | TheTechIdea.Beep.Winform.Controls |
| Inheritance | BeepAdvancedButton : BaseControl : Control |
| Implements | Uses IAdvancedButtonPainter interface for all painters |
| Partial files | BeepAdvancedButton.cs (1583 lines), BeepAdvancedButton.Layout.cs (143 lines) |
| Painter count | 30 individual painter classes + 4 NewsBanner sub-painters |
| Designer support | [ToolboxItem(true)], [ToolboxBitmap(typeof(Button))], [Category("Beep Controls")] |
Key Features
- 30+ painted visual styles — Solid, Icon, Text, Toggle, FAB, Ghost, Outlined, Link, Gradient, IconText, Chip, Contact, NavigationChevron, NeonGlow, NewsBanner, FlatWeb, LowerThird, StickerLabel, OutlinePill, AccentEdge, SpeechBubble, GradientSubButton, MiniGradientPill, GradientSpeechBubble, SplitGradient, IconCircleRight, SplitIconLeft, and more.
- Pluggable painter architecture — Each style is a standalone class implementing
IAdvancedButtonPainter. TheButtonPainterFactorymaps styles to painters at runtime. - Semantic intent system — Six intents (
Primary,Secondary,Tertiary,Destructive,Success,Neutral) provide automatic tokenized color mapping for consistent UX. - Customizable shapes — 7 shape options:
RoundedRectangle,Circle,Pill,Rectangle,Square,Split,Custom. Each style has a sensible default shape. - Rich sub-variant selectors — NewsBanner (21 variants), Contact (16 variants), Chevron (4 variants), FlatWeb (7 variants), LowerThird (8 variants), StickerLabel (4 variants).
- Smooth animation pipeline — 16ms animation timer drives hover/press transitions, ripple effect on click, and continuous loading spinner rotation.
- Loading state — Rotating spinner replaces content; optional click suppression while loading.
- Toggle behavior — Full on/off toggle with
ToggleChangedevent. Split shape provides independently clickable left/right areas with dedicated events. - Focus ring rendering — Keyboard-only focus ring with configurable thickness, offset, and radius delta.
- Accessible keyboard navigation — Full Space/Enter activation, Left/Right for split buttons, Tab support.
- Reduced motion support —
ReduceMotionproperty disables all animation transitions for accessibility. - DPI-aware sizing — Small (32px), Medium (40px), Large (48px) presets with automatic DPI scaling via
DpiScalingHelper. - Dual icon support —
IconLeftandIconRightproperties for left/right icon placement, plusImagePathfor main/leading icon. - Complete theme integration — Extends
BaseControl.ApplyTheme()to apply button-specific colors from the activeIBeepTheme. - Design-time safety — Fallback rendering with
DrawDesignTimeFallbackwhen theme is unavailable; error display withDrawDesignTimeError.
Inheritance & Architecture
Control
└── BaseControl (TheTechIdea.Beep.Winform.Controls.Base)
└── BeepAdvancedButton (TheTechIdea.Beep.Winform.Controls.Buttons.BeepAdvancedButton)
├── partial: BeepAdvancedButton.cs (1583 lines — core control, properties, events, overrides)
└── partial: BeepAdvancedButton.Layout.cs (143 lines — layout, shape logic, size helpers)
BaseControl provides double-buffering, classic painter fallback, border/shadow rendering, splash effects, hit-test infrastructure, and the full theme application pipeline. BeepAdvancedButton extends this with a custom painter system that bypasses traditional OnPaint in favor of DrawContent(Graphics g) where it assembles an AdvancedButtonPaintContext and delegates to the active IAdvancedButtonPainter.
The painter interface is intentionally minimal — a single void Paint(AdvancedButtonPaintContext context) method — allowing each style to have complete control over its rendering while consuming the same standardized context object that carries state, colors, bounds, shape, and animation data.
Styles & Sub-variants
The AdvancedButtonStyle enum defines 30 distinct visual styles. Each maps to a concrete painter class via ButtonPainterFactory. Changing ButtonStyle at runtime recreates the painter and resets the default shape for that style.
| Enum Value | Painter Class | Default Shape | Sub-variant Enum | Typical Use |
|---|---|---|---|---|
Solid | SolidButtonPainter | Pill | — | Primary action, CTA |
Outlined | OutlinedButtonPainter | Pill | — | Secondary action |
OutlinePill | OutlinePillButtonPainter | Pill | — | Thick colored outline with white fill |
Ghost | GhostButtonPainter | Pill | — | Subtle hover reveal |
Text | TextButtonPainter | Pill | — | Minimal text-only |
Link | LinkButtonPainter | Rectangle | — | Hyperlink-style |
FAB | FABButtonPainter | Circle | — | Floating Action Button (40–72px) |
Chip | ChipButtonPainter | Pill | — | Filter/tag chips |
Icon | IconButtonPainter | Pill | — | Icon-only button |
IconText | SplitColorButtonPainter | Pill | — | Icon + text split color |
Toggle | ToggleButtonPainter | Split | — | On/off toggle states |
Gradient | GradientButtonPainter | Pill | — | Gradient-filled button |
NeonGlow | NeonGlowButtonPainter | Pill | — | Glowing neon borders |
AccentEdge | AccentEdgeButtonPainter | Pill | — | White pill with colored edge strip |
Contact | ContactButtonPainter | Pill | ContactVariant (16 values) | Contact/CTA with icon sections |
LowerThird | LowerThirdButtonPainter | Rectangle | LowerThirdVariant (8 values) | Broadcast lower-third bars |
SpeechBubble | SpeechBubbleButtonPainter | Pill | — | Speech bubble with colored tail |
SplitIconLeft | SplitIconLeftButtonPainter | Pill | — | Icon left + text right with arrow tail |
SplitGradient | SplitGradientButtonPainter | Pill | — | Half-gradient half-white split |
IconCircleRight | IconCircleRightButtonPainter | Pill | — | Colored block with white icon circle on right |
FlatWeb | FlatWebButtonPainter | Rectangle | FlatWebVariant (7 values) | Flat web UI: badges, search bars, segments |
StickerLabel | StickerLabelButtonPainter | RoundedRectangle | StickerLabelVariant (4 values) | Comic/sticker style labels |
NewsBanner | NewsBannerButtonPainter | Pill | NewsBannerVariant (21 values) | News broadcast banners |
NavigationChevron | NavigationChevronButtonPainter | Pill | ChevronVariant (4 values) | Navigation with chevrons |
GradientSubButton | GradientSubButtonPainter | Pill | — | Large gradient with overlapping white sub-button |
MiniGradientPill | MiniGradientPillButtonPainter | Pill | — | Small gradient pill with icon |
GradientSpeechBubble | GradientSpeechBubblePainter | Pill | — | Gradient speech bubble with white accent line |
Enumerations
AdvancedButtonStyle
The primary visual variant selector. Has 30 values and determines which painter class renders the button.
public enum AdvancedButtonStyle
{
Solid, Outlined, OutlinePill, Ghost, Text, Link,
FAB, Chip, Icon, IconText, Toggle,
Gradient, NeonGlow, AccentEdge,
Contact, LowerThird, SpeechBubble,
SplitIconLeft, SplitGradient, IconCircleRight,
FlatWeb, StickerLabel, NewsBanner, NavigationChevron,
GradientSubButton, MiniGradientPill, GradientSpeechBubble,
SplitColor, // alias for IconText
IconTextButton, // value unused but reserved
GradientBadge // value unused but reserved
}
AdvancedButtonSize
Controls the DPI-scaled size preset. FAB buttons get special square sizing (40px, 56px, 72px).
public enum AdvancedButtonSize { Small, Medium, Large }
// Small = 80×32 (FAB: 40×40)
// Medium = 100×40 (FAB: 56×56) [default]
// Large = 120×48 (FAB: 72×72)
AdvancedButtonState
State machine for painter rendering. Determines color selection in GetBackgroundColor() and GetForegroundColor().
public enum AdvancedButtonState { Normal, Hover, Pressed, Disabled, Focused }
ButtonIntent
Semantic intent drives automatic color token mapping for consistent UX. Colors are derived from the active theme.
public enum ButtonIntent
{
Primary, // Accent color + lightened/darkened variants
Secondary, // Theme secondary color
Tertiary, // Theme default color
Destructive, // Red (220,53,69) palette
Success, // Green (25,135,84) palette
Neutral // Gray (108,117,125) palette
}
ButtonShape
Determines how the ButtonShapeHelper creates the GraphicsPath for clipping and border rendering.
public enum ButtonShape { RoundedRectangle, Circle, Pill, Rectangle, Square, Split, Custom }
NewsBannerVariant
21 explicit layout variants for news broadcast banners. When set to Auto, the painter uses heuristics to select a layout based on content and size.
public enum NewsBannerVariant
{
Auto,
CircleBadgeLeft, RectangleBadgeLeft, AngledBadgeLeft,
ChevronRight, ChevronBoth, FlagLeft,
AngledTwoTone, SlantedEdges, PillWithIcon,
BNLiveCircleBanner, BNSquareGreenBanner,
BreakingNewsGlobe, LightningBreakingNews, LightningBreakingNewsLive,
LiveWorldNewsPill, MorningLiveYellowBanner,
NewsLiveCirclePink, SportNewsCirclePill,
TwentyFourTVNews, TwentyFourWorldNewsHexagon,
WorldNewsGlobePill
}
ContactVariant
16 layout variants for contact/CTA buttons with icon-centric layouts. Auto heuristics select based on available icon paths and text length.
public enum ContactVariant
{
Auto, Standard, Outlined,
IconLeftSplit, IconRightSplit,
IconLeftCircle, IconRightCircle,
IconLeftAngled, IconLeftArrow,
IconCircleLeft1, IconSquareLeft2, IconCirclesLeftPill3,
IconCircleRightPill4, IconDiagonalLeft5, IconSquareLeft6,
IconArrowLeftPill7, IconInsidePillBorder8
}
ChevronVariant
public enum ChevronVariant { Auto, LeftIconRightChevron, LeftChevronRightIcon, BothChevrons, LeftIconCenterChevron }
FlatWebVariant
public enum FlatWebVariant
{
Auto, LeftBadgeAction, RightNotchSearch, SegmentedIconAction,
SearchPillNotch, ToolbarSegment, RightArrowTagSearch,
LeftPointTagSearch, MagnifierBubbleLeft
}
LowerThirdVariant
public enum LowerThirdVariant
{
Auto, HeadlineBar, LiveTagHeadline, ReportSplit,
TickerStrip, TickerChevron, LocationHeadlineBlock,
CompactLiveTag, ReportStacked
}
StickerLabelVariant
public enum StickerLabelVariant { Auto, SpeechBubble, CloudTag, BurstBadge, ComicRibbon }
Properties
All browsable properties are organized into Appearance, Behavior, and Variants categories in the Visual Studio property grid. Properties marked with [DefaultValue] have their defaults shown.
Style & Variant Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
ButtonStyle | AdvancedButtonStyle | Solid | Appearance | The style of the button (Solid, Icon, Text, Toggle, FAB, Ghost, etc.) |
NewsBannerVariant | NewsBannerVariant | Auto | Variants | Explicit news banner layout variant. Auto keeps heuristic layout selection. |
ContactVariant | ContactVariant | Auto | Variants | Explicit contact button layout variant. Auto keeps heuristic layout selection. |
ChevronVariant | ChevronVariant | Auto | Variants | Explicit navigation chevron layout variant. Auto keeps heuristic layout selection. |
FlatWebVariant | FlatWebVariant | Auto | Variants | Explicit flat web layout variant selector. Auto keeps heuristic layout selection. |
LowerThirdVariant | LowerThirdVariant | Auto | Variants | Explicit lower-third layout variant selector. Auto keeps heuristic layout selection. |
StickerLabelVariant | StickerLabelVariant | Auto | Variants | Explicit sticker label layout variant selector. Auto keeps heuristic layout selection. |
Intent | ButtonIntent | Primary | Behavior | Semantic intent used for tokenized color mapping (Primary, Secondary, Tertiary, Destructive, Success, Neutral). |
Shape & Size Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
ButtonSize | AdvancedButtonSize | Medium | Appearance | The size preset (Small=80×32, Medium=100×40, Large=120×48). FAB buttons use square sizing. |
Shape | ButtonShape | RoundedRectangle | Appearance | The shape of the button. Each style has a default shape that auto-applies on style change. |
Content Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
Text | string (override) | "Button" | Appearance | The text displayed on the button. Overrides BaseControl.Text. |
ImagePath | string | "" | Appearance | Path to the main image/icon. Uses BeepImagePathEditor in the designer. Maps to LeadingImagePath. |
IconLeft | string | "" | Appearance | Icon path for left side of button (for buttons with dual icons). |
IconRight | string | "" | Appearance | Icon path for right side of button. |
State Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
IsToggled | bool | false | Behavior | For toggle buttons, indicates if the button is toggled on. |
IsLoading | bool | false | Appearance | Shows a loading spinner animation. Rotation angle increments at 14°/tick. |
Animation & Behavior Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
ReduceMotion | bool | false | Behavior | When true, disables motion-heavy transitions and ripple animation. Snaps hover/press progress to target instantly. |
SuppressClickWhileLoading | bool | true | Behavior | When true, click activation is suppressed while loading is active. |
Focus Ring Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
ShowFocusRing | bool | true | Appearance | Displays a keyboard-only focus ring when focus-visible is active. |
FocusRingThickness | int | 2 | Appearance | Focus ring stroke thickness in pixels. Sanitized to minimum 1. |
FocusRingOffset | int | 2 | Appearance | Inset offset for focus ring rendering in pixels. Sanitized to minimum 0. |
FocusRingRadiusDelta | int | 2 | Appearance | Additional radius applied to focus ring over button border radius. Sanitized to minimum 0. |
Color Override Properties
| Property | Type | Default | Category | Description |
|---|---|---|---|---|
SolidBackground | Color | Color.Empty | Appearance | Background color for solid buttons. Overrides theme/intent-derived color when set. |
SolidForeground | Color | Color.White | Appearance | Foreground/text color for solid buttons. Overrides theme/intent-derived color when set. |
Public Methods
| Method | Signature | Description |
|---|---|---|
PerformClick | void PerformClick() | Programmatically triggers a click event. Calls OnClick(EventArgs.Empty). |
Toggle | void Toggle() | Toggles the button state by flipping IsToggled. Does NOT fire ToggleChanged directly (setter does not invoke). |
ApplyTheme | override void ApplyTheme() | Applies all theme colors, fonts, and styling from IBeepTheme. Sets button-specific properties (ButtonBackColor, ButtonForeColor, hover/press/disabled states) and triggers repaint. |
Events
| Event | EventArgs Type | Description |
|---|---|---|
ToggleChanged | ToggleChangedEventArgs | Raised when toggle state changes (for Toggle buttons). Provides bool IsToggled and string? AreaClicked ("Left", "Right", or null). |
LeftAreaClicked | EventArgs | Raised when the left half is clicked (for Split shape Toggle buttons). |
RightAreaClicked | EventArgs | Raised when the right half is clicked (for Split shape Toggle buttons). |
ToggleChangedEventArgs
public class ToggleChangedEventArgs : EventArgs
{
public bool IsToggled { get; set; }
public string? AreaClicked { get; set; } // "Left", "Right", or null
public ToggleChangedEventArgs(bool isToggled, string? areaClicked = null)
{
IsToggled = isToggled;
AreaClicked = areaClicked;
}
}
Theming & Color Tokens
BeepAdvancedButton integrates deeply with the Beep theming system. The ApplyTheme() override reads these theme tokens and applies them to corresponding control properties:
| Theme Token | Applied To | Used When |
|---|---|---|
ButtonBackColor | _solidBackground | Default background for painters |
ButtonForeColor | _solidForeground | Default foreground/text color |
ButtonHoverBackColor | HoverBackColor | Mouse hover background |
ButtonHoverForeColor | HoverForeColor | Mouse hover text color |
ButtonPressedBackColor | PressedBackColor | Mouse press background |
ButtonPressedForeColor | PressedForeColor | Mouse press text color |
ButtonSelectedBackColor | SelectedBackColor, FocusBackColor | Toggle-on background, focus indicator |
ButtonSelectedForeColor | SelectedForeColor, FocusForeColor | Toggle-on text, focus text |
DisabledBackColor | DisabledBackColor | Disabled state background |
DisabledForeColor | DisabledForeColor | Disabled state text |
ButtonBorderColor | BorderColor | Toggle border and border rendering |
ButtonFont | _textFont | Font used when UseThemeFont is true |
PrimaryColor | FocusRingColor | Focus ring stroke |
AccentColor | GlowColor, RippleColor, LoadingIndicatorColor | Special effects |
SecondaryColor | SecondaryColor | Paint context secondary color |
BadgeBackColor | BadgeColor | Badge background in painters |
Intent Color Resolution
The ResolveIntentColors() method maps each ButtonIntent to a set of colors. For Primary, it uses the theme's accent color; for Secondary, the secondary color. Destructive, Success, and Neutral use hardcoded industry-standard palettes. The method returns an internal IntentColors struct containing Background, Foreground, HoverBackground, and PressedBackground.
// Intent color mapping (simplified)
ButtonIntent.Primary: Accent color palette (theme-driven)
ButtonIntent.Secondary: Theme secondary color palette
ButtonIntent.Tertiary: Theme default button color palette
ButtonIntent.Destructive: RGB(220,53,69) red palette
ButtonIntent.Success: RGB(25,135,84) green palette
ButtonIntent.Neutral: RGB(108,117,125) gray palette
Animation Pipeline
The control uses a single System.Windows.Forms.Timer running at ~60 FPS (16ms interval). The OnAnimationTick handler updates four animation variables that feed into the painter via AdvancedButtonPaintContext:
| Animation Variable | Target | Speed | Description |
|---|---|---|---|
_hoverProgress (float 0–1) | IsHovered ? 1 : 0 | Lerp factor 0.22 | Controls hover transition blending for background/foreground |
_pressProgress (float 0–1) | IsPressed ? 1 : 0 | Lerp factor 0.30 | Controls press transition blending. Overrides hover in GetBackgroundColor |
_rippleProgress (float 0–1) | expands from 0 to 1 | +0.08 per tick | Ripple circle expansion from click point. Clamped to shape path. |
_loadingRotationAngle (float) | continuous rotation | +14° per tick | Loading spinner arc start angle. Resets to 0 when loading stops. |
The timer is automatically started/stopped via UpdateAnimationTimerState() which checks if any animation is in progress. When ReduceMotion is true, all animations snap to their target instantly and ripple is disabled.
The BaseButtonPainter class provides a Blend(Color from, Color to, float amount) utility used by GetBackgroundColor() and GetForegroundColor() to smoothly interpolate between state colors during hover and press transitions.
Rendering Pipeline
OnPaint→ BaseControl draws background/border via classic painter, then callsDrawContent(g).DrawContent(override) → Ensures painter is initialized, createsAdvancedButtonPaintContextwith all current state, colors, shape, and animation data. Resolves intent colors. Delegates to_currentPainter.Paint(context).- After painter completes →
DrawFocusRing(g, context)is called ifShowFocusRingis enabled and the control has keyboard focus. - Error fallback → If painter is null or throws,
DrawDesignTimeFallback(g)renders a simple bordered rectangle with centered text and a dashed design-time indicator.
The AdvancedButtonPaintContext object (26+ properties) carries everything the painter needs: bounds, state, text, icon paths, toggle/loading flags, shape, border/thickness, all color states, shadow config, animation progress values, focus ring parameters, font, intent, and size.
Accessibility & Keyboard
- Tab stop —
TabStop = trueby default.CanBeFocused = true. - Space / Enter — Activate the button. Triggers ripple animation at center. For Toggle+Split, Space/Enter activates the currently focused side (Left or Right).
- Arrow keys — For Split toggle buttons: Left selects left area, Right selects right area.
_keyboardSplitSelectRighttracks the selection. - Focus ring — Keyboard-only (visible when
_keyboardFocusVisible = true). Hidden on mouse click. Uses configurable thickness/offset/radius-delta. - Tab/ArrowKeys — Set
_keyboardFocusVisible = trueto show the focus ring. - Reduce motion — Disables all animation for users with motion sensitivity. Snaps hover/press states to target and disables ripple.
- Cursor —
Handon hover;Defaulton leave;Nowhen disabled (via helper).
Examples
Example 1: Solid Primary CTA Button
A standard call-to-action button with a primary intent, medium size, and pill shape. The colors are automatically derived from the active theme's accent color via the intent system.
var saveButton = new BeepAdvancedButton
{
Text = "Save Changes",
ButtonStyle = AdvancedButtonStyle.Solid,
ButtonSize = AdvancedButtonSize.Large,
Shape = ButtonShape.Pill,
Intent = ButtonIntent.Primary,
ImagePath = "/icons/save.svg"
};
saveButton.Click += (s, e) => SaveDocument();
Example 2: Loading State with Click Suppression
Shows a spinning loader while an async operation runs. Click events are suppressed during loading by default via SuppressClickWhileLoading. The button's Text is hidden when loading and a rotating arc is displayed in its place.
var submitBtn = new BeepAdvancedButton
{
Text = "Submit Order",
ButtonStyle = AdvancedButtonStyle.Gradient,
Intent = ButtonIntent.Success,
SuppressClickWhileLoading = true
};
submitBtn.Click += async (s, e) =>
{
submitBtn.IsLoading = true;
try
{
await SubmitOrderAsync();
submitBtn.Text = "Order Placed!";
}
finally
{
submitBtn.IsLoading = false;
}
};
Example 3: Split Toggle Button with Left/Right Areas
A Toggle-style button with a Split shape that divides the button into independently clickable left and right halves. Left click sets IsToggled = true, right click sets IsToggled = false. Each side fires its own event, and ToggleChanged provides which area was clicked.
var modeToggle = new BeepAdvancedButton
{
Text = "Edit / Preview",
ButtonStyle = AdvancedButtonStyle.Toggle,
Shape = ButtonShape.Split,
ButtonSize = AdvancedButtonSize.Medium,
IsToggled = false
};
modeToggle.ToggleChanged += (s, e) =>
{
if (e.IsToggled)
SwitchToEditMode();
else
SwitchToPreviewMode();
};
modeToggle.LeftAreaClicked += (s, e) =>
Console.WriteLine("Left (Edit) area clicked");
modeToggle.RightAreaClicked += (s, e) =>
Console.WriteLine("Right (Preview) area clicked");
Example 4: FAB (Floating Action Button) with Reduced Motion
A circular floating action button. FAB automatically uses Circle shape and DPI-scaled square dimensions. Motion is disabled for accessibility, so hover/press transitions snap instantly and ripple is suppressed.
var fab = new BeepAdvancedButton
{
ButtonStyle = AdvancedButtonStyle.FAB,
ButtonSize = AdvancedButtonSize.Medium, // 56×56 at 96 DPI
ImagePath = "/icons/plus.svg",
Intent = ButtonIntent.Primary,
ReduceMotion = true,
ShowFocusRing = true,
FocusRingThickness = 3,
FocusRingOffset = 4
};
fab.Click += (s, e) => CreateNewProject();
Controls.Add(fab);
fab.Location = new Point(ClientSize.Width - 80, ClientSize.Height - 80);
fab.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
Example 5: News Banner with Explicit Variant
A news/broadcast-style banner button with a breaking news globe icon, LIVE badge, and red-themed destructive intent for visual urgency.
var breakingNews = new BeepAdvancedButton
{
Text = "Markets Surge on Policy Shift",
ButtonStyle = AdvancedButtonStyle.NewsBanner,
NewsBannerVariant = NewsBannerVariant.BreakingNewsGlobe,
Intent = ButtonIntent.Destructive,
ButtonSize = AdvancedButtonSize.Large
};
breakingNews.Click += (s, e) => NavigateToNewsArticle();
Example 6: Contact Button with Right Circle Icon
A contact-styled CTA button with a circular icon container on the right side, useful for messaging or contact actions.
var contactBtn = new BeepAdvancedButton
{
Text = "Chat with Support",
ButtonStyle = AdvancedButtonStyle.Contact,
ContactVariant = ContactVariant.IconCircleRightPill4,
IconRight = "/icons/chat.svg",
Intent = ButtonIntent.Success,
ButtonSize = AdvancedButtonSize.Medium
};
contactBtn.Click += (s, e) => OpenChatWindow();
File Architecture
The BeepAdvancedButton control is spread across 42 files organized into a clean directory structure:
| File / Directory | Responsibility |
|---|---|
BeepAdvancedButton.cs | Main partial class (1583 lines): properties, events, constructor, DrawContent override, mouse/keyboard handlers, animation pipeline, theme application, intent color resolution, focus ring drawing, design-time fallback rendering. |
BeepAdvancedButton.Layout.cs | Layout partial class (143 lines): split-area hit registration, left/right area click handling, area hover state tracking, default shape mapping per style, size calculation (DPI-scaled). |
Enums/AdvancedButtonEnums.cs | All public enumerations (286 lines): AdvancedButtonStyle (30 values), AdvancedButtonSize, AdvancedButtonState, ButtonIntent, ButtonShape, NewsBannerVariant (21 values), ContactVariant (16 values), ChevronVariant, FlatWebVariant, LowerThirdVariant, StickerLabelVariant. |
Models/AdvancedButtonModels.cs | Data models (216 lines): ToggleChangedEventArgs, AdvancedButtonPaintContext (40+ properties), AdvancedButtonMetrics (DPI-aware sizing for Small/Medium/Large). |
Models/AdvancedButtonPaintContract.cs | Layout contract (122 lines): AdvancedButtonPaintTokens, AdvancedButtonLayoutSlices, AdvancedButtonPaintContract (static factory for tokens/slices with radius resolution). |
Painters/IAdvancedButtonPainter.cs | Interface (16 lines): Single void Paint(AdvancedButtonPaintContext context) method. |
Painters/BaseButtonPainter.cs | Abstract base painter (613 lines): Common rendering helpers (rounded rect paths, shadow, ripple, icon drawing, text drawing, loading spinner, color blending, shape-aware fill/draw, focus ring primitive, fallback icon methods for globe/lightning/sport/alert, LIVE badge drawing). |
Painters/ButtonPainterFactory.cs | Factory (108 lines): Maps AdvancedButtonStyle to concrete painters. Specialized factory method for NewsBannerVariant → sub-painter routing. |
Helpers/BeepAdvancedButtonHelper.cs | Layout helper (213 lines): Calculates ideal width, content bounds (icon+text), rounded-corner hit testing, cursor selection, shadow offset by state, text measurement. |
Helpers/ButtonShapeHelper.cs | Shape utility (224 lines): Static methods for GetCornerRadiusForShape, CreateShapePath (handles Circle/Ellipse, Pill, RoundedRectangle, Rectangle, Split, Square), CreatePartialRoundedRectangle (selective corner rounding), FillShape, DrawShape, GetAdjustedBoundsForShape. |
Painters/ (30 individual files) | One painter class per button style, each extending BaseButtonPainter and overriding Paint(AdvancedButtonPaintContext). Subdirectory Painters/NewsBanner/ contains 4 specialized sub-painters (CircleBadge, Bar, Arrow, Angled, IconBadge). |
Complete Painter Directory
| Painter Class | Style(s) Served | Key Rendering Features |
|---|---|---|
SolidButtonPainter | Solid | Filled background with intent-derived color, rounded path |
OutlinedButtonPainter | Outlined | Transparent fill with colored border |
OutlinePillButtonPainter | OutlinePill | Thick colored outline, white fill, pill shape |
GhostButtonPainter | Ghost | Transparent, subtle hover background reveal |
TextButtonPainter | Text | No background/border, text-only with hover color change |
LinkButtonPainter | Link | Underline-style hyperlink appearance |
FABButtonPainter | FAB | Circular with elevation shadow, icon-centered |
ChipButtonPainter | Chip | Pill-shaped tag, optional close icon, badge support |
IconButtonPainter | Icon | Icon-only rendering, centered |
IconTextButtonPainter | IconText | Icon + text with gap |
SplitColorButtonPainter | IconText (factory alias) | Split color rendering for icon+text |
ToggleButtonPainter | Toggle | On/off visual states, split left/right rendering |
GradientButtonPainter | Gradient | Linear gradient background fill |
NeonGlowButtonPainter | NeonGlow | Glow effect with neon-colored borders |
AccentEdgeButtonPainter | AccentEdge | White pill with colored edge strip on one side |
ContactButtonPainter | Contact | 16 layout variants with icon circle/square/arrow backgrounds |
LowerThirdButtonPainter | LowerThird | 8 variants: headline bars, LIVE tags, ticker strips, report splits |
SpeechBubbleButtonPainter | SpeechBubble | Speech bubble shape with colored tail |
SplitIconLeftButtonPainter | SplitIconLeft | Icon left block with text right and arrow tail |
SplitGradientButtonPainter | SplitGradient | Half gradient, half white split rendering |
IconCircleRightButtonPainter | IconCircleRight | Colored block with white icon circle on right |
StickerLabelButtonPainter | StickerLabel | 4 variants: speech bubble, cloud tag, burst badge, comic ribbon |
FlatWebButtonPainter | FlatWeb | 7 variants: badge actions, search notch, segmented toolbar, etc. |
NavigationChevronButtonPainter | NavigationChevron | 4 variants with chevron placement relative to icon |
NewsBannerButtonPainter | NewsBanner | Routes to sub-painters; defines NewsBannerStyle enum |
NewsCircleBadgePainter | NewsBanner (5 variants) | Circle badge styles: Live, Sport, 24TV, Pink news |
NewsBarPainter | NewsBanner (5 variants) | Bar/badge styles: Breaking News, Live, Flag, Morning |
NewsArrowPainter | NewsBanner (3 variants) | Arrow/chevron styles: Hexagon, single/double chevron |
NewsAngledPainter | NewsBanner (3 variants) | Angled/slanted edge styles: two-tone, slanted |
NewsIconBadgePainter | NewsBanner (5 variants) | Icon badge styles: Globe, Lightning, World News pill |
GradientSubButtonPainter | GradientSubButton | Large gradient background with overlapping white sub-button |
MiniGradientPillButtonPainter | MiniGradientPill | Small gradient pill with centered icon |
GradientSpeechBubblePainter | GradientSpeechBubble | Gradient speech bubble with white accent line |
GradientBadgeButtonPainter | GradientBadge (reserved) | Gradient badge button rendering |