Siticone Button
The SiticoneButton is a robust WinForms control delivering Material Design aesthetics, high-performance
rendering, and advanced user interaction states.
It extends standard button functionality with features like fluid animations, haptic-like visual feedback, and comprehensive state management including toggling, long-press detection, and system theme monitoring.
Appearance Properties
Properties controlling the core visual style of the button, including background colors, gradients, and text appearance across different states.
| Property | Type | Description & Usage Example |
|---|---|---|
ButtonBackColor |
Color | btn.ButtonBackColor = Color.FromArgb(20, 20, 20); The primary background color of the button in its resting (normal) state. If gradients are enabled, this acts as the starting color. |
HoverBackColor |
Color | btn.HoverBackColor = Color.FromArgb(40, 40, 40); The background color applied when the mouse pointer is positioned over the control. Creates a visual cue for interactivity. |
PressedBackColor |
Color | btn.PressedBackColor = Color.Black; The background color applied while the left mouse button is held down over the control. |
TextColor |
Color | btn.TextColor = Color.WhiteSmoke; The default color of the text caption. Ensure high contrast against the ButtonBackColor. |
HoverTextColor |
Color | btn.HoverTextColor = Color.Cyan; The color of the text caption when the mouse hovers over the button. Useful for subtle emphasis. |
DisabledTextColor |
Color |
btn.DisabledTextColor = Color.Gray;
The text color used when the Enabled property is set to false.
|
ReadOnlyTextColor |
Color |
btn.ReadOnlyTextColor = Color.Silver;
The text color used when IsReadOnly is true.
Visually distinguishes read-only state from disabled state.
|
GradientBackground |
bool | btn.GradientBackground = true; When enabled, fills the button background with a gradient transitioning from ButtonBackColor to GradientColor. |
GradientColor |
Color | btn.GradientColor = Color.Magenta; The secondary color used for the gradient fill. Ignored if GradientBackground is false. |
GradientMode |
LinearGradientMode | btn.GradientMode = LinearGradientMode.ForwardDiagonal; Determines the direction and angle of the gradient fill (e.g., Vertical, Horizontal, Diagonal). |
Shape & Borders
Control the physical geometry of the button, allowing for rounded corners, pill shapes, or perfect circles.
| Property | Type | Description & Usage Example |
|---|---|---|
BorderColor |
Color | btn.BorderColor = Color.Red; The color of the border stroke drawn around the button. |
BorderWidth |
int | btn.BorderWidth = 2; The thickness of the border in pixels. Set to 0 to remove the border. |
IsRadial |
bool | btn.IsRadial = true; If true, forces the button into a circular shape by automatically setting corner radii to half the smallest dimension. Overrides individual corner properties. |
CornerRadiusTopLeft |
int | btn.CornerRadiusTopLeft = 10; |
CornerRadiusTopRight |
int | btn.CornerRadiusTopRight = 10; |
CornerRadiusBottomLeft |
int | btn.CornerRadiusBottomLeft = 5; |
CornerRadiusBottomRight |
int | btn.CornerRadiusBottomRight = 5; |
Interaction & Behavior
Settings that define how the user interacts with the control, including state toggling, long-press detection, and access permissions.
| Property | Type | Description & Usage Example |
|---|---|---|
IsToggleButton |
bool | btn.IsToggleButton = true; If true, the button acts like a checkbox, maintaining an On/Off state (IsToggled) when clicked. |
IsToggled |
bool | if (btn.IsToggled) { /* Active */ } Gets or sets the current toggle state. Only relevant if IsToggleButton is true. |
EnableLongPress |
bool | btn.EnableLongPress = true; Enables the detection of a long-press gesture, firing the LongPressed event. |
LongPressDurationMS |
int | btn.LongPressDurationMS = 2000; The time in milliseconds the user must hold the mouse button down to trigger the LongPressed event. |
IsReadOnly |
bool | btn.IsReadOnly = true; When true, the button appears interactive but standard clicks are intercepted. It fires the ReadOnlyInteraction event instead of Click, useful for "locked" or "premium" features. |
DialogResult |
DialogResult | btn.DialogResult = DialogResult.OK; Standard WinForms property. If set, clicking the button closes the parent form and returns this result. |
Enabled |
bool | btn.Enabled = false; Disables the control entirely. It will not respond to any mouse events and will be drawn with DisabledTextColor. |
CustomCursor |
Cursor | btn.CustomCursor = Cursors.Hand; Defines the cursor displayed when the mouse hovers over the button. |
ContextMenuStripEx |
ContextMenuStrip | btn.ContextMenuStripEx = myRightClickMenu; Assigns a ContextMenuStrip that automatically appears when the button is right-clicked. |
Animation & Effects
Configuration for visual feedback loops like Material Design ripples, particle explosions, shake effects, and press scaling.
| Property | Type | Description & Usage Example |
|---|---|---|
EnableRippleEffect |
bool | btn.EnableRippleEffect = true; Toggles the expanding circle animation (Material Design ripple) upon clicking. |
RippleColor |
Color | btn.RippleColor = Color.White; |
RippleOpacity |
float | btn.RippleOpacity = 0.2f; The alpha transparency of the ripple effect (0.0 to 1.0). |
RippleRadiusMultiplier |
float | btn.RippleRadiusMultiplier = 1.0f; Controls how large the ripple grows relative to the button size. |
EnablePressAnimation |
bool | btn.EnablePressAnimation = true; If enabled, the button physically shrinks slightly when pressed to simulate depth. |
PressAnimationScale |
float | btn.PressAnimationScale = 0.95f; The scale factor (e.g., 0.95 = 95% size) the button shrinks to when held down. |
HoverTransitionDuration |
int | btn.HoverTransitionDuration = 300; Time in ms for color fading when the mouse enters/leaves the control. |
PressTransitionDuration |
int | btn.PressTransitionDuration = 100; Time in ms for color fading when the button is pressed. |
UseParticles |
bool | btn.UseParticles = true; When true, small particles explode from the click location for a "confetti" effect. |
ParticleColor |
Color | btn.ParticleColor = Color.Gold; |
ParticleCount |
int | btn.ParticleCount = 20; |
CanShake |
bool | btn.CanShake = true; Enables the Shake API and automatically triggers a shake animation if a ReadOnly button is clicked. |
ShakeDuration |
int | btn.ShakeDuration = 500; |
ShakeIntensity |
int | btn.ShakeIntensity = 8; |
CanBeep |
bool | btn.CanBeep = true; If true, plays a system sound when a ReadOnly button is clicked. |
Glow & Shadow
| Property | Type | Description & Usage Example |
|---|---|---|
EnableShadow |
bool | btn.EnableShadow = true; Draws a drop shadow behind the button to create elevation. |
ShadowColor |
Color | btn.ShadowColor = Color.Black; |
ShadowOffset |
Point | btn.ShadowOffset = new Point(2, 4); |
ShadowBlur |
int | btn.ShadowBlur = 15; The softness radius of the shadow. |
CanGlow |
bool | btn.CanGlow = true; If true, the button emits a pulsating glow effect when hovered. |
GlowColor |
Color | btn.GlowColor = Color.FromArgb(100, Color.Blue); |
GlowRadius |
float | btn.GlowRadius = 25f; |
GlowIntensity |
int | btn.GlowIntensity = 200; |
Badge System
A built-in system to display notifications or numeric counts directly on the button.
| Property | Type | Description & Usage Example |
|---|---|---|
BadgeValue |
int | btn.BadgeValue = 5; The number displayed in the badge. Setting this to 0 automatically hides the badge. |
BadgeBackColor |
Color | btn.BadgeBackColor = Color.Red; |
BadgeValueForeColor |
Color | btn.BadgeValueForeColor = Color.White; |
BadgeFont |
Font | btn.BadgeFont = new Font("Arial", 8f); |
CenterTextAndBadgeTogether |
bool | btn.CenterTextAndBadgeTogether = true; If true, treats the button text and badge as a single unit and centers them together horizontally. |
TextBadgeSpacing |
int | btn.TextBadgeSpacing = 10; The pixel distance between the text and the badge when centered together. |
BadgeAlignment |
StringAlignment |
btn.BadgeAlignment = StringAlignment.Far;
Controls badge position (Near/Center/Far) when CenterTextAndBadgeTogether is false.
|
Image & Text
| Property | Type | Description & Usage Example |
|---|---|---|
Text |
string | btn.Text = "Submit"; |
Font |
Font | btn.Font = new Font("Segoe UI", 12f); |
NormalFontStyle |
FontStyle | btn.NormalFontStyle = FontStyle.Regular; |
HoverFontStyle |
FontStyle | btn.HoverFontStyle = FontStyle.Bold; |
PressedFontStyle |
FontStyle | btn.PressedFontStyle = FontStyle.Italic; |
TextAlign |
ContentAlignment | btn.TextAlign = ContentAlignment.MiddleCenter; |
ButtonTextLeftPadding |
int | btn.ButtonTextLeftPadding = 15; |
EnableTextWrapping |
bool | btn.EnableTextWrapping = true; |
AutoSizeBasedOnText |
bool | btn.AutoSizeBasedOnText = true; Automatically resizes the button to fit the text and image content. |
RightToLeft |
RightToLeft | btn.RightToLeft = RightToLeft.Yes; |
ButtonImage |
Image | btn.ButtonImage = Properties.Resources.Icon; |
ImageSize |
Size | btn.ImageSize = new Size(24, 24); |
ImageAlign |
ContentAlignment | btn.ImageAlign = ContentAlignment.MiddleLeft; |
ImagePadding |
int | btn.ImagePadding = 5; |
System & Performance
| Property | Type | Description & Usage Example |
|---|---|---|
UltraFastPerformance |
bool | btn.UltraFastPerformance = true; Disables all complex animations (ripples, particles, glows) and effects. Essential for using the button in DataGridViews or lists with hundreds of items to maintain UI responsiveness. |
UseAdvancedRendering |
bool | btn.UseAdvancedRendering = true; |
CurrentSystemTheme |
ThemeMode | var theme = btn.CurrentSystemTheme; Read-only property that returns the current operating system theme (Light/Dark). |
IsSystemThemeMonitoringEnabled |
bool | btn.IsSystemThemeMonitoringEnabled = true; If true, the button automatically detects Windows theme changes and fires the SystemThemeChanged event. |
TooltipText |
string | btn.TooltipText = "Save changes"; |
HintText |
string | btn.HintText = "Contextual help"; Displays an extended help tooltip, often used for instructional text. |
Public Methods
// Simulates a button click programmatically.
// This triggers the Click event, plays standard animations (like Ripple),
// and executes any logic associated with the button's action.
// Useful for keyboard shortcuts or triggering the button from other UI elements.
public void TriggerAction()
{
siticoneButton1.PerformClick();
}
// Manually triggers the horizontal shake animation.
// This is primarily used for visual feedback during form validation
// (e.g., when a user submits a form with missing required fields).
// Requires the 'CanShake' property to be set to true.
if (string.IsNullOrEmpty(username.Text))
{
// Shake the button to indicate an error to the user
loginButton.StartShaking();
}
// Immediately terminates any active shake animation and resets
// the button's visual transform to its original position (0,0).
// Use this if you need to interrupt the animation before it finishes naturally.
loginButton.StopShaking();
Events
Comprehensive event system for monitoring button interactions and state changes.
// 1. Standard Click Event
// Fires when the button is clicked by the mouse or triggered via keyboard (Space/Enter).
// This is the primary event for handling button logic.
btn.Click += (s, e) =>
{
SaveData();
};
// 2. LongPressed Event
// Fires only after the user holds the left mouse button down for the duration
// specified in 'LongPressDurationMS'.
// Requires 'EnableLongPress = true'.
// Ideal for showing advanced options or context menus without cluttering the UI.
btn.LongPressed += (s, e) =>
{
ShowContextMenu();
};
// 3. ToggleChanged Event
// Fires when the 'IsToggled' state changes.
// Requires 'IsToggleButton = true'.
// Use this to handle logic for on/off switches, like enabling a dark mode or muting audio.
btn.ToggleChanged += (s, e) =>
{
if (btn.IsToggled)
{
EnableFeature();
}
else
{
DisableFeature();
}
};
// 4. ReadOnlyInteraction Event
// Fires when a user attempts to click the button while 'IsReadOnly = true'.
// This event intercepts the standard click.
// It is useful for "Premium" or "Locked" features
// where you want to show the user why they cannot perform the action.
// Setting 'e.WasHandled = true' prevents the default shake/beep feedback.
btn.ReadOnlyInteraction += (s, e) =>
{
if (e.Type == InteractionType.Click)
{
MessageBox.Show("This feature requires a Pro subscription.");
e.WasHandled = true; // Suppress automatic shake/beep
}
};
// 5. StateChanged Event
// Fires whenever the visual state of the button changes (e.g., from Normal to Hover, or Hover to Pressed).
// Provides access to 'OldState', 'NewState', and animation details.
// Useful for logging user behavior or debugging custom visual transitions.
btn.StateChanged += (s, e) =>
{
Debug.WriteLine($"State changed from {e.OldState} to {e.NewState}");
Debug.WriteLine($"Is animating: {e.IsAnimating}, Duration: {e.TransitionDuration}");
};
// 6. AnimationCompleted Event
// Fires when a specific animation (Ripple, Shake, Glow, etc.) finishes playing.
// Can be used to chain animations or trigger logic *after* a visual effect concludes.
btn.AnimationCompleted += (s, e) =>
{
if (e.AnimationType == AnimationType.Shake)
{
// Focus the input field after the error shake finishes
FocusInput();
}
};
// 7. AnimationEffectStarted Event
// Fires at the exact moment a visual effect (like a Ripple or Particle explosion) begins.
// Provides the location and expected duration of the effect.
btn.AnimationEffectStarted += (s, e) =>
{
if (e.EffectType == AnimationType.Ripple)
{
Debug.WriteLine($"Ripple started at {e.Location}");
}
};
// 8. ThemeChanged Event
// Fires when the 'CurrentSystemTheme' property is manually updated or changes programmatically.
// Use this to re-apply color palettes if you are handling custom theming logic.
btn.ThemeChanged += (s, e) =>
{
Debug.WriteLine($"Theme changed from {e.OldTheme} to {e.NewTheme}");
ApplyThemeColors(e.NewTheme);
};
// 9. SystemThemeChanged Event
// Fires automatically when the Windows Operating System theme changes (e.g., user switches Windows to Dark Mode).
// Requires 'IsSystemThemeMonitoringEnabled = true'.
// allows your app to adapt instantly to OS preferences.
btn.SystemThemeChanged += (s, e) =>
{
Debug.WriteLine($"Windows System Theme is now: {e.SystemTheme}");
};
Designer Experience & Smart Tags
The SiticoneButton includes advanced design-time features accessible via the Visual Studio Designer Smart Tag menu (accessible by clicking the small arrow on the top-right of the control).
| Feature | Description |
|---|---|
Theme Presets |
Instantly apply professional color schemes without writing code. Available presets include:
|
Settings Clipboard |
Copy Settings: Copies all visual properties (Colors, Radius, Borders, Effects) from the selected button. Paste Settings: Applies the copied properties to another SiticoneButton instance. Useful for duplicating complex button styles across your application forms. |
Accessibility & Input
Built-in support for keyboard navigation and system accessibility settings.
| Feature | Behavior |
|---|---|
Keyboard Support |
Users can trigger the button click event using the Space or Enter keys when the button has focus. The visual "Pressed" state is simulated during the key press. |
High Contrast |
The control automatically detects SystemInformation.HighContrast mode.
When active, it overrides custom colors with SystemColors.Control, SystemColors.ControlText, and SystemColors.Highlight to ensure readability for visually impaired users.
|
Additional Properties
Properties that control advanced features and standard control behavior.
| Property | Type | Description & Usage |
|---|---|---|
AccessibleName |
string | btn.AccessibleName = "Submit Form"; The name reported to accessibility clients (like screen readers). Defaults to the button Text. |
AccessibleDescription |
string | btn.AccessibleDescription = "Submits data"; A detailed description reported to accessibility clients. |
AccessibleRole |
AccessibleRole | btn.AccessibleRole = AccessibleRole.PushButton; Defines the UI role. Automatically toggles between PushButton and CheckButton based on IsToggleButton. |
TabStop |
bool | btn.TabStop = true; Determines if the user can tab to this control. |
Size |
Size | btn.Size = new Size(150, 50); The dimensions of the control. If AutoSizeBasedOnText is true, this is calculated automatically. |
Location |
Point | btn.Location = new Point(100, 50); The coordinates of the upper-left corner of the control relative to its container. |
Visible |
bool | btn.Visible = false; Determines whether the control is visible or hidden. |
BackColor |
Color | btn.BackColor = Color.Transparent; Overridden to always be Color.Transparent to support non-rectangular shapes. Use ButtonBackColor for the actual fill. |
Enumerations
Enumerations used by the SiticoneButton control for state management and theming.
// Defines the possible theme modes for the button.
public enum ThemeMode
{
// Indicates a light theme (typically bright backgrounds, dark text).
Light,
// Indicates a dark theme (dark backgrounds, light text).
Dark,
// Indicates that the theme is manually configured or does not match system presets.
Custom
}
// Represents the various visual states of the button.
// This enum is passed in the StateChanged event to indicate transitions.
public enum ButtonState
{
// The default state when the mouse is not interacting with the button.
Normal,
// The mouse pointer is over the button.
Hover,
// The left mouse button is held down over the control.
Pressed,
// The button is disabled (Enabled = false).
Disabled,
// The button is in ReadOnly mode (IsReadOnly = true).
ReadOnly,
// The button is in the "On" state (IsToggleButton = true).
Toggled,
// Transitional states indicating an ongoing animation.
AnimatingToNormal,
AnimatingToHover,
AnimatingToPressed
}
// Identifies the specific type of animation being played.
// Used in AnimationCompleted and AnimationEffectStarted events.
public enum AnimationType
{
// Color fade transition to Hover state.
Hover,
// Color fade transition to Pressed state.
Press,
// Color fade transition back to Normal state.
Release,
// The expanding circle effect (Material Design ripple).
Ripple,
// Horizontal vibration effect (often for errors).
Shake,
// Pulsating glow effect on hover.
Glow,
// Confetti-like particle explosion effect.
Particle,
// Generic state change transition.
StateTransition
}
// Defines the specific mouse action that triggered a ReadOnlyInteraction event.
public enum InteractionType
{
// A standard left-click.
Click,
// A double-click event.
DoubleClick,
// A right-click event (often used for context menus).
RightClick,
// A middle mouse button click.
MiddleClick,
// The mouse pointer entered the control.
Hover,
// The mouse pointer left the control.
Leave
}
Detailed Usage Examples
Example 1: Toggle Button for Audio Control
This example demonstrates how to create a button that maintains state (Mute/Unmute). It dynamically changes its background color, text, and tooltip based on whether it is currently toggled.
// Creates a toggle button for audio mute/unmute control.
// The button acts as a switch: "Mute" (Green) when off, "Unmute" (Red) when on.
private SiticoneButton CreateToggleButton()
{
var button = new SiticoneButton
{
Text = "Mute",
Size = new Size(120, 40),
// Enable toggle behavior
IsToggleButton = true,
// Default Appearance (Normal/Off State)
ButtonBackColor = Color.SeaGreen,
TextColor = Color.White,
HoverBackColor = Color.MediumSeaGreen,
PressedBackColor = Color.ForestGreen,
// Effects
EnableRippleEffect = true,
RippleColor = Color.White,
// Styling
CornerRadiusTopLeft = 8,
CornerRadiusTopRight = 8,
CornerRadiusBottomLeft = 8,
CornerRadiusBottomRight = 8
};
// Handle the ToggleChanged event to update visuals and logic
button.ToggleChanged += (sender, e) =>
{
var btn = (SiticoneButton)sender;
if (btn.IsToggled)
{
// State: Toggled ON (Audio Muted)
// Visuals change to Red to indicate "Muted" state
btn.Text = "Unmute";
btn.ButtonBackColor = Color.Crimson;
btn.HoverBackColor = Color.LightCoral;
btn.PressedBackColor = Color.Firebrick;
btn.TooltipText = "Click to restore audio";
// Execute Logic
MuteAudio();
}
else
{
// State: Toggled OFF (Audio Active)
// Visuals revert to Green
btn.Text = "Mute";
btn.ButtonBackColor = Color.SeaGreen;
btn.HoverBackColor = Color.MediumSeaGreen;
btn.PressedBackColor = Color.ForestGreen;
btn.TooltipText = "Click to silence audio";
// Execute Logic
UnmuteAudio();
}
};
return button;
}
Example 2: Visual Haptics (Validation Shake)
This example shows how to use the StartShaking method to provide immediate feedback when a form validation fails (e.g., an empty password field).
// Example of using the shake animation to reject a login attempt.
private void BtnLogin_Click(object sender, EventArgs e)
{
// 1. Validate the password input
if (string.IsNullOrWhiteSpace(txtPassword.Text))
{
// 2. Configure shake properties for this specific feedback
btnLogin.CanShake = true;
btnLogin.ShakeDuration = 800; // 800ms duration
btnLogin.ShakeIntensity = 7; // Moderate intensity (1-10)
// 3. Trigger the shake animation manually
btnLogin.StartShaking();
// 4. Provide visual text feedback
lblStatus.Text = "Password is required!";
lblStatus.ForeColor = Color.Red;
// 5. Provide auditory feedback (System Beep)
if (btnLogin.CanBeep)
{
SystemSounds.Exclamation.Play();
}
// Stop execution here since validation failed
return;
}
// 6. Proceed with login if validation passes
PerformLogin(txtUsername.Text, txtPassword.Text);
}
Example 3: Dynamic Badge Updates
The badge system is used here to display a live notification count. The code increments a counter, updates the badge text, and centers it automatically.
// Tracks the number of unread messages
private int _notificationCount = 0;
// Method called when a new message arrives
private void ReceiveNewMessage()
{
_notificationCount++;
// 1. Update the numeric value on the badge
btnInbox.BadgeValue = _notificationCount;
// 2. Configure badge styling
btnInbox.BadgeBackColor = Color.Red;
btnInbox.BadgeValueForeColor = Color.White;
btnInbox.BadgeFont = new Font("Segoe UI", 8f, FontStyle.Bold);
// 3. Ensure the text ("Inbox") and Badge ("5") are centered together
btnInbox.CenterTextAndBadgeTogether = true;
btnInbox.TextBadgeSpacing = 8;
// 4. Optional: Shake the button gently to grab attention
if (_notificationCount == 1)
{
btnInbox.ShakeIntensity = 4;
btnInbox.StartShaking();
}
// 5. Update tooltip for accessibility
btnInbox.TooltipText = $"You have {_notificationCount} new message(s)";
}
// Method called when user opens the inbox
private void BtnInbox_Click(object sender, EventArgs e)
{
// Reset count and clear badge
_notificationCount = 0;
btnInbox.BadgeValue = 0; // Setting to 0 hides the badge
btnInbox.TooltipText = "Inbox";
OpenInbox();
}
Example 4: Async Operation with Loading State
This example handles an asynchronous download. It updates the button to a "Loading" state (disabled, gray, wait cursor) and disables animations to improve performance during the heavy operation.
// Handles an async download task with visual state updates
private async void BtnDownload_Click(object sender, EventArgs e)
{
var btn = (SiticoneButton)sender;
// 1. Store original state to restore later
string originalText = btn.Text;
Color originalColor = btn.ButtonBackColor;
try
{
// 2. Set "Loading" state
btn.Enabled = false;
// Prevent double-clicks
btn.Text = "Downloading...";
btn.CustomCursor = Cursors.WaitCursor;
btn.ButtonBackColor = Color.Gray; // Visual "Disabled" look
// 3. Enable UltraFastPerformance to save resources during heavy work
btn.UltraFastPerformance = true;
// 4. Simulate the heavy task (3 seconds)
await Task.Delay(3000);
// 5. Show Success State
btn.Text = "Done!";
btn.ButtonBackColor = Color.Green;
await Task.Delay(1000);
}
catch (Exception ex)
{
// 6. Handle Errors
btn.Text = "Failed";
btn.ButtonBackColor = Color.Red;
MessageBox.Show(ex.Message);
}
finally
{
// 7. Restore Original State
btn.Enabled = true;
btn.Text = originalText;
btn.ButtonBackColor = originalColor;
btn.CustomCursor = Cursors.Hand;
// 8. Re-enable animations
btn.UltraFastPerformance = false;
}
}
Example 5: Theme-Aware Button with System Integration
This code creates a button that listens for Windows system theme changes (e.g., toggling between Dark Mode and Light Mode in Windows Settings) and updates its colors automatically.
// Creates a button that automatically adapts to system theme changes.
private SiticoneButton CreateThemeAwareButton()
{
var button = new SiticoneButton
{
Text = "Theme Aware",
Size = new Size(150, 40),
// Critical: Enable monitoring of Windows Registry for theme changes
IsSystemThemeMonitoringEnabled = true
};
// Subscribe to the SystemThemeChanged event
button.SystemThemeChanged += (s, e) =>
{
var btn = (SiticoneButton)s;
// Apply colors based on the new detected theme
switch (e.SystemTheme)
{
case ThemeMode.Light:
// Configure for Light Mode
btn.ButtonBackColor = Color.White;
btn.TextColor = Color.Black;
btn.BorderColor = Color.LightGray;
btn.HoverBackColor = Color.FromArgb(240, 240, 240);
break;
case ThemeMode.Dark:
// Configure for Dark Mode
btn.ButtonBackColor = Color.FromArgb(45, 45, 45);
btn.TextColor = Color.White;
btn.BorderColor = Color.FromArgb(80, 80, 80);
btn.HoverBackColor = Color.FromArgb(60, 60, 60);
break;
}
};
// Trigger the logic once initially to set the startup color
// based on the current system state.
button.CurrentSystemTheme = button.CurrentSystemTheme;
return button;
}
Example 6: Advanced Read-Only Interaction
This example sets up a "locked" feature button. Instead of disabling it (which looks dead), we make it ReadOnly. It intercepts clicks to show an upgrade dialog, creating a better UX for upsell opportunities.
// Configures a button to act as a "Premium Feature" lock.
private void InitializeLockedButton()
{
var btnLocked = new SiticoneButton
{
Text = "Export to PDF",
// Set ReadOnly: Looks active but standard Click is blocked
IsReadOnly = true,
// Enable default feedback (Shake/Beep) for basic clicks
CanShake = true,
CanBeep = true,
// Styling for ReadOnly state
ButtonBackColor = Color.LightGray,
ReadOnlyTextColor = Color.DimGray,
TooltipText = "Premium feature locked"
};
// Handle the interaction manually
btnLocked.ReadOnlyInteraction += (s, e) =>
{
// Check what kind of interaction occurred
switch (e.Type)
{
case InteractionType.Click:
// Explain WHY it's locked
MessageBox.Show(
"Exporting to PDF requires a Pro License.\nClick here to upgrade.",
"Feature Locked",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
// Important: Set WasHandled to true to stop the default
// shake/beep because we handled it with a MessageBox.
e.WasHandled = true;
break;
case InteractionType.Hover:
// Make it slightly darker on hover even though it's locked
btnLocked.HoverBackColor = Color.Silver;
break;
}
};
}
Example 7: Circular Button with Image
Demonstrates creating a circular button (Floating Action Button style) using IsRadial.
It positions an icon in the center and floats the button in the bottom-right corner.
// Creates a circular Floating Action Button (FAB).
private SiticoneButton CreateFABButton()
{
var fabButton = new SiticoneButton
{
Text = "", // No text for FAB
Size = new Size(56, 56), // Standard FAB size
// IsRadial=true automatically makes it circular regardless of corner radius
IsRadial = true,
// Colors (Material Blue)
ButtonBackColor = Color.DodgerBlue,
HoverBackColor = Color.FromArgb(30, 144, 255),
PressedBackColor = Color.RoyalBlue,
// Shadow for elevation
EnableShadow = true,
ShadowColor = Color.FromArgb(60, 0, 0, 0),
ShadowOffset = new Point(0, 3),
ShadowBlur = 8,
// Visuals
EnableRippleEffect = true,
RippleColor = Color.White,
CustomCursor = Cursors.Hand
};
// Load and set icon image
fabButton.ButtonImage = Image.FromFile("add_icon.png");
fabButton.ImageSize = new Size(24, 24);
fabButton.ImageAlign = ContentAlignment.MiddleCenter;
// Anchor to bottom-right of the form
fabButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
fabButton.Location = new Point(
this.ClientSize.Width - fabButton.Width - 20,
this.ClientSize.Height - fabButton.Height - 20
);
return fabButton;
}
Example 8: Gradient Button with Multiple Effects
Shows how to combine gradients, glows, shadows, and particles to create a "Premium" style CTA (Call to Action) button.
// Creates a high-impact "Premium" button with multiple visual effects.
private SiticoneButton CreatePremiumButton()
{
var premiumButton = new SiticoneButton
{
Text = "GET PREMIUM",
Size = new Size(200, 55),
Font = new Font("Segoe UI", 11f, FontStyle.Bold),
// 1. Gradient Background (Pink to Violet)
GradientBackground = true,
ButtonBackColor = Color.FromArgb(255, 105, 180), // Start: Hot Pink
GradientColor = Color.FromArgb(138, 43, 226), // End: Blue Violet
GradientMode = LinearGradientMode.ForwardDiagonal,
// 2. Text Styling
TextColor = Color.White,
HoverFontStyle = FontStyle.Bold | FontStyle.Underline,
// 3. Rounded Geometry
CornerRadiusTopLeft = 25,
CornerRadiusTopRight = 25,
CornerRadiusBottomLeft = 25,
CornerRadiusBottomRight = 25,
// 4. Drop Shadow (Colored to match button)
EnableShadow = true,
ShadowColor = Color.FromArgb(100, 255, 20, 147),
ShadowOffset = new Point(0, 5),
ShadowBlur = 15,
// 5. Glow Effect on Hover
CanGlow = true,
GlowColor = Color.FromArgb(80, 255, 255, 255),
GlowRadius = 30f,
// 6. Particle Explosion on Click
UseParticles = true,
ParticleColor = Color.Gold,
ParticleCount = 30,
// 7. Press Animation (Scale down)
EnablePressAnimation = true,
PressAnimationScale = 0.95f,
CustomCursor = Cursors.Hand
};
return premiumButton;
}