Theme and Appearance

This feature manages the form’s visual styling by applying theme variants and associated color palettes across the title bar, control buttons, and general background.

Overview

This section details the properties and behaviors that control the overall visual appearance of the form. The theme functionality centers around the ThemeVariant property, which applies a set of theme colors to multiple elements including the title bar, control buttons, and background. By selecting a theme variant (for example, dark or light), the form’s colors are automatically updated, ensuring consistency across the interface.


Key Points

Aspect
Details
Default Value (Sample)
Example Value

ThemeVariant

Specifies a detailed theme variant that controls the form’s color scheme and visual styling.

DarkDefault (or a theme default)

LightDefault, CustomDark, etc.

Global Color Settings

Theme application automatically sets colors for the title bar, control buttons, and background.

Values defined in ThemesCollection

Customized color palette as defined in ThemesCollection

Synchronization

Changing the theme variant triggers an immediate update and redraw of the form’s visual elements.

Automatic update on property set

Instant visual refresh upon theme change


Best Practices

Recommendation
Explanation
Example in Code

Use ThemeVariant for consistency

Apply a pre-defined theme variant to ensure a uniform and professional appearance throughout the app.

myForm.ThemeVariant = FormThemeVariant.LightDefault;

Combine manual customization with themes

While themes provide a base set of colors, adjust specific color properties only if needed for branding.

myForm.TitleBarBackColor = Color.DodgerBlue; (after theme application)

Test across multiple displays

Ensure that theme colors and scaling appear correctly on different monitors and DPI settings.

Verify appearance on both high-DPI and standard screens.


Common Pitfalls

Issue
Cause
Prevention/Remedy

Inconsistent color application

Overriding theme-applied colors without coordinating with the theme’s palette.

Update custom colors only when necessary and after the theme is applied.

Delayed visual updates

Changing the ThemeVariant property after the form is already rendered might require an explicit redraw.

Call Invalidate() on the form or use Application.DoEvents() if needed.

Clashing with manual settings

Manually set colors may conflict with those provided by the theme variant.

Decide on a base theme first, then apply minor adjustments if needed.


Usage Scenarios

Scenario
How It Works
Sample Code

Standard Application Theming

Developers apply a theme variant to give the application a consistent dark or light look.

csharp\nvar myForm = new SiticoneForm {\n ThemeVariant = FormThemeVariant.DarkDefault\n};\nApplication.Run(myForm);

Brand Customization with Overrides

A base theme is applied, and specific color properties are overridden to match company branding.

csharp\nvar myForm = new SiticoneForm {\n ThemeVariant = FormThemeVariant.LightDefault,\n TitleBarBackColor = Color.DodgerBlue,\n TitleBarForeColor = Color.White\n};\nApplication.Run(myForm);

Responsive Visual Updates

Changing the theme at runtime immediately updates the form’s appearance, useful for user-selectable themes.

csharp\nmyForm.ThemeVariant = FormThemeVariant.LightDefault;\nmyForm.Invalidate(true);


Real Life Usage Scenarios

Scenario
Explanation
How to Implement

Enterprise Applications

Maintain a corporate color scheme across all forms by applying a custom theme variant.

Create a custom theme in ThemesCollection and set myForm.ThemeVariant to that custom variant.

Multi-User Applications with Theme Options

Allow users to select between light and dark modes from settings; theme changes reflect immediately.

Provide a settings dialog that changes ThemeVariant based on user selection and refreshes the UI.

Accessibility-Oriented Designs

Adjust color contrasts via theme variants to meet accessibility standards (e.g., high contrast themes).

Use a high-contrast theme variant and allow further customization if needed.


Troubleshooting Tips

Problem
Potential Cause
Suggested Fix

Theme changes not reflecting

The form may not be invalidating/redrawing properly after theme change.

Explicitly call Invalidate(true) after setting a new ThemeVariant.

Overridden colors conflicting

Manual color settings might conflict with theme defaults.

Apply theme changes first, then adjust only specific colors that require manual override.

Visual artifacts on high-DPI screens

Scaling issues might occur if icon sizes or fonts are not adjusted after theme application.

Ensure that DPI scaling is taken into account by using dynamic scaling for IconSize and font properties.


Review

Aspect
Notes

Consistency

The Theme & Appearance feature provides a centralized way to ensure all UI elements adhere to a chosen color scheme.

Flexibility

Developers can apply a full theme variant while still retaining the option to override individual properties.

Ease of Integration

Changing the theme is as simple as setting a property, making it easy to adapt the UI for different user preferences.


Summary

Summary Point
Description

Unified Styling

ThemeVariant allows developers to set a cohesive color palette across the entire form with one property.

Customization with Flexibility

While a base theme is applied, manual adjustments allow for fine-tuning and branding.

Immediate Visual Feedback

Changing the theme at runtime refreshes the UI, providing a dynamic and responsive user experience.


Additional Code Example

Below is a complete integration sample demonstrating how to initialize a SiticoneForm with customized theme and appearance settings:

using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI; // Ensure the namespace is referenced correctly

public class MainForm
{
    public static void Main()
    {
        // Initialize the form with a base theme variant.
        var myForm = new SiticoneForm
        {
            FormTitle = "My Themed Application",
            ThemeVariant = FormThemeVariant.DarkDefault,
            // Optionally override specific theme colors after the base theme is applied.
            TitleBarBackColor = Color.FromArgb(45, 45, 48),
            TitleBarForeColor = Color.White,
            // Adjust control box button colors if needed
            CloseButtonHoverForeColor = Color.Red,
            RotateCloseIconOnHover = true,
        };

        // Optional: Subscribe to an event to see when theme changes might trigger a refresh.
        myForm.Load += (sender, e) =>
        {
            Console.WriteLine("Form loaded with the selected theme.");
        };

        Application.Run(myForm);
    }
}

Additional Resources

Resource
Description
Link/Reference

Code Comments

Review the inline comments in the provided code for insights on how themes are applied.

Refer to the original code snippet.

Official WinForms Guides

Microsoft’s documentation on WinForms can provide further background on styling and themes.

Community Tutorials

Forums and tutorials for WinForms provide real-world examples of theme integration.

Check .NET community sites and blogs.


This documentation should serve as a comprehensive guide for integrating and customizing the Theme & Appearance feature of your SiticoneForm. Each section is designed to help developers understand available options, follow best practices, and troubleshoot common issues while implementing theme-based customization.

Last updated