Appearance Customization

A feature that allows developers to adjust the visual aspects of the close button, including colors, icon style, size, line thickness, and corner rounding, to match their application’s aesthetic.

Overview

The Appearance Customization feature exposes several properties to modify the look and feel of the close button control. These properties include icon colors for various states, icon size and thickness, the style of the icon, and the roundness of the button’s corners. The following documentation provides detailed information, integration samples, and guidance for using these properties effectively.


Properties Summary

Property
Description
Default Value
Sample Usage

IconColor

Sets the default color of the close icon.

Color.FromArgb(64, 64, 64)

closeButton.IconColor = Color.Black;

HoverColor

Sets the icon color when the mouse hovers over the button.

Color.FromArgb(232, 17, 35)

closeButton.HoverColor = Color.Orange;

PressedColor

Sets the icon color when the button is pressed.

Color.FromArgb(241, 112, 122)

closeButton.PressedColor = Color.Red;

GlowColor

Defines the color for the glow effect when enabled.

Color.Red

closeButton.GlowColor = Color.Yellow;

IconSize

Specifies the overall size of the close icon.

10

closeButton.IconSize = 16;

IconThickness

Specifies the thickness of the icon’s lines.

2

closeButton.IconThickness = 3;

CloseButtonStyle

Determines the style of the close icon (e.g., Cross, Modern, Dot, Power, Custom).

ButtonStyle.Cross

closeButton.CloseButtonStyle = SiticoneCloseButton.ButtonStyle.Modern;

CornerRadius

Adjusts the roundness of the button's corners.

0

closeButton.CornerRadius = 5.0f;


Code Examples

Example 1: Basic Appearance Customization

The following sample demonstrates how to set up the close button with custom colors, icon size, and style in a WinForms application.

using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;

public class MainForm : Form
{
    private SiticoneCloseButton closeButton;

    public MainForm()
    {
        InitializeComponents();
    }

    private void InitializeComponents()
    {
        // Initialize the close button control
        closeButton = new SiticoneCloseButton
        {
            IconColor = Color.DarkSlateGray,
            HoverColor = Color.OrangeRed,
            PressedColor = Color.Maroon,
            GlowColor = Color.Yellow,
            IconSize = 16,
            IconThickness = 3,
            CloseButtonStyle = SiticoneCloseButton.ButtonStyle.Modern,
            CornerRadius = 5.0f,
            Location = new Point(10, 10)
        };

        // Add the control to the form
        Controls.Add(closeButton);

        // Form settings
        Text = "Appearance Customization Demo";
        Size = new Size(300, 200);
    }

    [STAThread]
    public static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new MainForm());
    }
}

Example 2: Dynamic Appearance Changes

This example shows how to modify the appearance properties at runtime, such as in response to user settings or themes.

private void ToggleTheme(bool darkMode)
{
    if (darkMode)
    {
        closeButton.IconColor = Color.LightGray;
        closeButton.HoverColor = Color.White;
        closeButton.PressedColor = Color.Gray;
        closeButton.GlowColor = Color.LightBlue;
    }
    else
    {
        closeButton.IconColor = Color.FromArgb(64, 64, 64);
        closeButton.HoverColor = Color.FromArgb(232, 17, 35);
        closeButton.PressedColor = Color.FromArgb(241, 112, 122);
        closeButton.GlowColor = Color.Red;
    }
    // Redraw the control to apply new appearance settings.
    closeButton.Invalidate();
}

Key Points

Aspect
Details

Customizable Colors

Developers can set distinct colors for normal, hover, and pressed states to align with their application's theme.

Icon Style Flexibility

The control offers multiple icon styles including traditional, modern, dot, power, and custom image options.

Scalable Design

The IconSize and IconThickness properties ensure that the control can be scaled appropriately for different UI sizes without loss of visual quality.

Rounded Corners

The CornerRadius property allows the control’s shape to be adjusted to match modern UI trends or branding guidelines.


Best Practices

Recommendation
Explanation

Use Consistent Themes

Match the IconColor, HoverColor, and PressedColor with your overall application theme for a cohesive look and feel.

Validate Property Values

Ensure that IconSize and IconThickness are set to positive values to avoid rendering issues.

Test Across Resolutions

Since the control scales with IconSize and CornerRadius, verify the appearance on different resolutions and DPI settings.

Leverage Designer Support

Utilize the Visual Studio designer to adjust properties visually during design time, ensuring quicker iterations.


Common Pitfalls

Pitfall
Description
Recommendation

Overly Small IconSize

Setting IconSize too small may render the icon illegible.

Use a minimum value (e.g., 8 or above) to ensure clarity.

Inconsistent Color Schemes

Mismatched color settings for normal, hover, and pressed states can lead to a jarring user experience.

Use a consistent color palette or theme to maintain a unified design.

Ignoring DPI Scaling

Failing to test on high-DPI displays may result in a blurry or misaligned control.

Test the control on different DPI settings and adjust IconSize or IconThickness accordingly.


Usage Scenarios

Scenario
Description
Code Sample Integration

Themed Applications

Applications that support multiple themes can dynamically adjust the appearance of the close button to match user-selected themes.

See Example 2 above.

Custom UI Designs

Applications with unique branding can leverage the custom appearance properties to integrate the close button seamlessly.

Customize properties such as IconColor, IconSize, and CornerRadius.

Accessibility Focused UI

For high contrast or accessibility modes, properties like HighContrastMode (from the control) can be used to modify visual settings.

Use complementary color values for better readability.


Review

Review Point
Consideration

Property Exposure

The appearance properties are public and well-categorized under "Appearance", making them easy to locate and modify.

Code Integration

Sample code provided demonstrates both static and dynamic integration, making it easy for developers to adopt and test.

Visual Consistency

By exposing multiple related properties, the control helps maintain consistency across different UI elements within an application.


Summary

The Appearance Customization feature of the close button control empowers developers to tailor the visual presentation to suit their application's design. Through properties such as IconColor, HoverColor, PressedColor, IconSize, IconThickness, CloseButtonStyle, and CornerRadius, developers can ensure that the control not only functions well but also integrates aesthetically with the rest of the UI. Proper usage and testing across various themes and DPI settings are recommended to achieve optimal results.


Additional Resources

Resource
Description
Link / Code Example Reference

Property Configuration

Detailed code samples and best practices for configuring appearance properties.

See provided code examples above.

Visual Studio Designer

Utilize the Visual Studio designer to preview changes in real time.

Integrated within Visual Studio UI.

DPI Scaling Guidelines

Reference guidelines for handling DPI scaling in WinForms.

MSDN documentation on High DPI support.


By following this comprehensive documentation, developers can effectively integrate and customize the close button’s appearance to meet their design requirements while avoiding common pitfalls and leveraging best practices.

Last updated