TwoState Theme Switch
The SiticoneTwoStateThemeSwitch is a specialized, high-fidelity toggle button specifically designed for Light/Dark mode switching.
Unlike generic switches, it features morphing animations (Sun to Moon), physics-based spring interactions, and deep customization options for creating a premium user experience.
Core State
Primary properties for controlling the toggle state and system integration.
| Property | Type | Description & Usage Example |
|---|---|---|
IsDarkMode |
bool | themeSwitch.IsDarkMode = true; The main state of the control. Setting this triggers the transition animation between the Sun and Moon icons. |
ListenToSystemTheme |
bool | themeSwitch.ListenToSystemTheme = true; If enabled, the control automatically synchronizes its state with the Windows OS theme settings in real-time. |
Preset |
ThemePreset | themeSwitch.Preset = ThemePreset.Forest; Applies a pre-configured color scheme (e.g., Default, Success, Warning, Violet). Setting individual colors changes this to 'Custom'. |
Sun & Moon Customization
Extensive options to tailor the appearance of the celestial icons.
| Property | Type | Description |
|---|---|---|
SunColor / MoonColor |
Color | The fill colors for the Sun and Moon icons respectively. |
SunRayCount |
int | The number of rays surrounding the sun (0-24). |
SunRayLength |
float | Multiplier for the length of the sun rays (0.1 - 3.0). |
MoonCrescentSize |
float | Controls the shadow overlap to define how "full" the moon appears (0.0 - 1.0). |
EnableSunRaysAnimation |
bool | If true, the sun rays rotate continuously when the sun is visible. |
EnableMoonAnimation |
bool | If true, the moon performs a gentle pulsing animation when visible. |
Physics & Animation
Fine-tune the feel of the switch with physics-based spring settings and easing functions.
| Property | Type | Description |
|---|---|---|
AnimationDuration |
int | Total time in milliseconds for the theme transition animation. |
AnimationEasing |
AnimationEasingType | The mathematical curve for interpolation (Linear, EaseIn, EaseOut, Bounce, etc.). |
EnableSpringAnimation |
bool | Enables a physics-based "bouncy" scale effect when clicked. |
SpringStiffness |
float | Controls the rigidity of the spring. Higher values mean faster, snappier movement. |
SpringDamping |
float | Controls how quickly the oscillation settles. Lower values equal more wobble. |
Visual Effects
Additional graphical enhancements for depth and feedback.
| Property | Type | Description |
|---|---|---|
EnableDropShadow |
bool | Adds a soft, high-quality shadow beneath the button for elevation. |
ShadowDepth |
int | The radius/blur size of the drop shadow. |
EnableRippleEffect |
bool | Triggers a Material Design-style expanding ripple on click. |
RippleColor |
Color | The color of the ripple effect. Alpha transparency is handled automatically. |
UltraFastMode |
bool | themeSwitch.UltraFastMode = true; Disables shadows, advanced gradients, and complex animations for maximum performance on low-end hardware. |
Events
// Fired AFTER the theme has successfully toggled.
themeSwitch.IsDarkModeChanged += (sender, e) =>
{
if (e.IsDarkMode)
ApplyDarkTheme();
else
ApplyLightTheme();
};
// Fired BEFORE the theme changes. Allows cancellation.
themeSwitch.ThemeChanging += (sender, e) =>
{
if (HasUnsavedChanges())
{
e.Cancel = true; // Prevent the toggle
MessageBox.Show("Please save your work first.");
}
};
Enumerations
public enum ThemePreset
{
Custom, Default, Light, Dark, Success, Warning, Info,
Red, Crimson, Violet, Orange, Pink, Teal, Azure, Forest, Monochrome
}
Usage Examples
Example 1: Basic Theme Toggle Integration
Standard implementation for switching application colors.
public MainForm()
{
InitializeComponent();
// Set default state
themeSwitch.IsDarkMode = false;
// Subscribe to change event
themeSwitch.IsDarkModeChanged += (s, e) =>
{
Color back = e.IsDarkMode ? Color.FromArgb(30, 30, 30) : Color.White;
Color fore = e.IsDarkMode ? Color.White : Color.Black;
this.BackColor = back;
this.ForeColor = fore;
// Propagate to controls...
};
}
Example 2: System Sync & Custom Styling
Configures the switch to follow the OS theme and applies a custom "Cyberpunk" aesthetic.
private void SetupThemeSwitch()
{
// 1. Sync with Windows 10/11 Theme
themeSwitch.ListenToSystemTheme = true;
// 2. Customize Colors (Cyberpunk Look)
themeSwitch.DarkModeBackColor = Color.Black;
themeSwitch.DarkModeHoverColor = Color.FromArgb(20, 20, 20);
themeSwitch.MoonColor = Color.Cyan;
themeSwitch.MoonShadowColor = Color.Magenta;
// 3. Customize Animations
themeSwitch.EnableMoonAnimation = true; // Pulse
themeSwitch.MoonPulseSize = 0.1f;
themeSwitch.EnableRippleEffect = true;
themeSwitch.RippleColor = Color.LimeGreen;
}
Example 3: Read-Only Interaction Handling
Shows how to handle user clicks when the switch is disabled/read-only (e.g., when theme is forced by admin policy).
private void ConfigureRestrictedSwitch()
{
themeSwitch.IsReadOnly = true;
themeSwitch.CanShake = true; // Visual feedback on click
themeSwitch.ReadOnlyInteractionAttempt += (s, e) =>
{
toolTip1.Show("Theme is managed by your organization.", themeSwitch, 0, -30, 2000);
};
}
Designer Smart Tags
The SiticoneTwoStateThemeSwitch includes a comprehensive Smart Tag panel in Visual Studio IDE.