Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Get Device Theme

Siticone Get Device Theme

The SiticoneGetDeviceTheme is a specialized non-visual component that enables your Windows Forms application to react instantly to operating system theme changes. It monitors the Windows Registry and System Events to detect when the user switches between Light and Dark modes in Windows Settings, or when High Contrast accessibility mode is toggled.

Theme State Properties

Read-only properties that provide the current state of the operating system.

Property Type Description & Usage Example
IsDark bool bool appMode = deviceTheme.IsDark; Returns true if the "Choose your default app mode" setting in Windows is set to Dark. This is the primary property for styling your application window.
IsSystemDark bool bool sysMode = deviceTheme.IsSystemDark; Returns true if the "Choose your default Windows mode" (Taskbar, Start Menu) is set to Dark. Useful for determining tray icon colors (e.g., white icon for dark taskbar).
IsHighContrast bool bool hiCon = deviceTheme.IsHighContrast; Returns true if Windows High Contrast accessibility mode is active. Your app should disable custom colors and use system colors when this is true.

Configuration

Control the monitoring behavior.

Property Type Description & Usage Example
Enabled bool deviceTheme.Enabled = true; Enables or disables the internal event listeners. Defaults to true. Disabling stops the component from reacting to OS changes.

Public Methods

ForceUpdate()
// Manually re-reads the registry and system settings to update the properties.
// Triggers events if the state has changed since the last check.
deviceTheme1.ForceUpdate();
Use this if you suspect settings have changed but events haven't fired, or to initialize your UI state at startup.

Events

Event Wiring
// 1. AppThemeChanged
// Fires when the user toggles "Default app mode" (Light/Dark).
deviceTheme.AppThemeChanged += (s, e) => 
{
                ApplyAppTheme(e.IsDark);
};

// 2. SystemThemeChanged
// Fires when the user toggles "Default Windows mode" (Taskbar/Start).
deviceTheme.SystemThemeChanged += (s, e) => 
{
                UpdateTrayIcon(e.IsDark);
};

// 3. HighContrastChanged
// Fires when High Contrast mode is toggled.
deviceTheme.HighContrastChanged += (s, isHighContrast) => 
{
                if (isHighContrast) EnableAccessibilityMode();
};

Detailed Usage Examples

Example 1: Auto-Theming Forms

Automatically switch your form's colors when the user changes Windows settings.

C# - Form Theming
public void SetupThemeMonitor()
{
    siticoneGetDeviceTheme1.AppThemeChanged += (s, e) => 
    {
                ApplyTheme(e.IsDark);
    };
    
                // Apply initial state on startup
                ApplyTheme(siticoneGetDeviceTheme1.IsDark);
}

private void ApplyTheme(bool isDark)
{
                if (isDark)
    {
                this.BackColor = Color.FromArgb(32, 32, 32);
                this.ForeColor = Color.White;
        lblTitle.ForeColor = Color.LightGray;
    }
                else
    {
                this.BackColor = Color.White;
                this.ForeColor = Color.Black;
        lblTitle.ForeColor = Color.DimGray;
    }
}

Example 2: Smart Tray Icon

Windows Taskbar color is independent of App color. Use IsSystemDark to ensure your tray icon is visible (White icon for Dark taskbar, Dark icon for Light taskbar).

C# - Tray Icon Awareness
private void ConfigureTrayIcon()
{
    siticoneGetDeviceTheme1.SystemThemeChanged += (s, e) => 
    {
                UpdateIcon(e.IsDark);
    };
    
                UpdateIcon(siticoneGetDeviceTheme1.IsSystemDark);
}

private void UpdateIcon(bool isTaskbarDark)
{
                // If taskbar is dark, use light icon. If light, use dark icon.
    notifyIcon1.Icon = isTaskbarDark ? Properties.Resources.Icon_White : Properties.Resources.Icon_Black;
}

Example 3: High Contrast Safety

Ensure your app respects accessibility standards by detecting High Contrast mode.

C# - Accessibility Check
private void CheckAccessibility()
{
                // Disable custom styling if High Contrast is on
                if (siticoneGetDeviceTheme1.IsHighContrast)
    {
        siticoneButton1.UseAdvancedRendering = false;
        siticoneButton1.FillColor = SystemColors.Control;
        siticoneButton1.ForeColorCustom = SystemColors.ControlText;
        siticoneButton1.BorderColor = SystemColors.Highlight;
        siticoneButton1.BorderThickness = 2;
    }
}