Corner Radius Customization

Corner Radius Customization allows developers to adjust the rounding of each corner of the progress bar, enabling a more refined and tailored look that can match the application's overall design.

Overview

The Corner Radius Customization feature provides control over the curvature of the progress bar's corners. With properties to individually set the radii for the top-left, top-right, bottom-right, and bottom-left corners, as well as a synchronization option to apply a uniform radius, this feature allows for flexible styling that can adapt to various design requirements.


Feature Details

Property
Type
Default Value
Description

TopLeftRadius

float

0

Sets the radius for the top-left corner of the progress bar.

TopRightRadius

float

0

Sets the radius for the top-right corner of the progress bar.

BottomRightRadius

float

0

Sets the radius for the bottom-right corner of the progress bar.

BottomLeftRadius

float

0

Sets the radius for the bottom-left corner of the progress bar.

SyncCornerRadius

bool

false

When enabled, synchronizes all corner radii so that updating one updates all four corners.

SetCornerRadii()

Method

N/A

Allows setting all four corner radii at once without relying on the synchronization feature.


Key Points

Key Point
Explanation

Individual Control

Each corner can be customized separately to create unique shapes and visual styles.

Uniform Appearance Option

The synchronization feature (SyncCornerRadius) simplifies the process of applying a consistent radius to all corners.

Dynamic Updates

Changes to any of the radius properties trigger an immediate redraw, ensuring the UI reflects the new settings promptly.


Best Practices

Best Practice
Details

Use Consistent Values for Uniformity

When a uniform appearance is desired, enable SyncCornerRadius to reduce code complexity and maintain consistency.

Test Across Different Sizes

Verify the appearance of rounded corners at various control sizes to ensure the design scales appropriately.

Consider the Overall UI Theme

Adjust the corner radii to complement the overall design language of your application, whether modern or traditional.


Common Pitfalls

Pitfall
Explanation

Inconsistent Appearance

Changing one corner’s radius without enabling SyncCornerRadius may result in a disjointed look if not intentionally styled.

Overly Large Radii

Setting a radius that is too large relative to the control's size may distort the progress bar or hide important visual cues.

Neglecting Dynamic Redraws

Failing to update the control’s appearance immediately after changing radius properties might lead to a mismatch between design expectations and the rendered output.


Usage Scenarios

Scenario
How to Apply Corner Radius Customization

Modern Flat UI Design

Use a moderate uniform radius (e.g., 5-10 pixels) to achieve a modern, flat design that is visually appealing and in line with contemporary UI trends.

Custom Shaped Controls

Customize each corner individually to create non-standard shapes that stand out and add a unique visual identity to the application.

Responsive Design Adjustments

Dynamically adjust corner radii based on control size or window dimensions to ensure a consistent look across different resolutions and devices.


Code Examples

Example 1: Uniform Corner Radius Using SyncCornerRadius

This example demonstrates how to apply a uniform radius to all corners using the synchronization property.

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

public class UniformCornerForm : Form
{
    private SiticoneHLineProgress progressBar;

    public UniformCornerForm()
    {
        InitializeComponent();
        InitializeProgressBar();
    }

    private void InitializeComponent()
    {
        this.Text = "Uniform Corner Radius Demo";
        this.Size = new Size(400, 200);
    }

    private void InitializeProgressBar()
    {
        progressBar = new SiticoneHLineProgress
        {
            Minimum = 0,
            Maximum = 100,
            Value = 75,
            Location = new Point(20, 50),
            Size = new Size(350, 14),
            TopLeftRadius = 8,  // Set initial radius for one corner
            SyncCornerRadius = true // Enable synchronization to apply the same radius to all corners
        };

        this.Controls.Add(progressBar);
    }

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

Example 2: Custom Individual Corner Radii

This example shows how to set each corner's radius individually, allowing for a custom-shaped progress bar.

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

public class CustomCornerForm : Form
{
    private SiticoneHLineProgress progressBar;

    public CustomCornerForm()
    {
        InitializeComponent();
        InitializeProgressBar();
    }

    private void InitializeComponent()
    {
        this.Text = "Custom Corner Radii Demo";
        this.Size = new Size(400, 250);
    }

    private void InitializeProgressBar()
    {
        progressBar = new SiticoneHLineProgress
        {
            Minimum = 0,
            Maximum = 100,
            Value = 50,
            Location = new Point(20, 70),
            Size = new Size(350, 14),
            TopLeftRadius = 5,
            TopRightRadius = 15,
            BottomRightRadius = 10,
            BottomLeftRadius = 0,
            SyncCornerRadius = false // Disable synchronization to allow custom values per corner
        };

        this.Controls.Add(progressBar);
    }

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

Example 3: Using SetCornerRadii Method

This example demonstrates how to use the provided helper method to set all four corner radii at once.

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

public class SetCornerRadiiForm : Form
{
    private SiticoneHLineProgress progressBar;

    public SetCornerRadiiForm()
    {
        InitializeComponent();
        InitializeProgressBar();
    }

    private void InitializeComponent()
    {
        this.Text = "SetCornerRadii Method Demo";
        this.Size = new Size(400, 200);
    }

    private void InitializeProgressBar()
    {
        progressBar = new SiticoneHLineProgress
        {
            Minimum = 0,
            Maximum = 100,
            Value = 80,
            Location = new Point(20, 50),
            Size = new Size(350, 14),
            SyncCornerRadius = false // Disable sync to allow manual setting via method
        };

        // Set all corner radii to 12 using the helper method.
        progressBar.SetCornerRadii(12, 12, 12, 12);

        this.Controls.Add(progressBar);
    }

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

Review

Aspect
Review Comments

Flexibility

The feature offers both individual and synchronized control over corner radii, catering to a wide range of design requirements.

Ease of Integration

The properties are straightforward to implement, and the helper method simplifies setting all radii at once.

Visual Impact

Adjusting the corner radii can significantly enhance the progress bar's aesthetics, ensuring it aligns with the application's visual theme.


Summary

Corner Radius Customization enables developers to fine-tune the appearance of the progress bar by adjusting the curvature of its corners. Whether applying a uniform radius with synchronization or customizing each corner individually, this feature provides the necessary flexibility to integrate the progress bar seamlessly with modern or custom UI designs. Utilizing the provided properties and helper method ensures a consistent and visually appealing presentation across various usage scenarios.


Additional Considerations

Consideration
Explanation

Consistent Design Language

When integrating with other UI elements, ensure that the corner radius values complement the overall design for a cohesive look.

Responsiveness to Size Changes

Test the appearance of rounded corners at different control sizes to avoid disproportionate curvature.

Performance Impact

While the customization of corner radii is generally lightweight, ensure that dynamic updates to these properties do not interfere with performance during rapid UI changes.

This comprehensive documentation for the Corner Radius Customization feature provides a detailed guide, including usage scenarios, best practices, code examples, and additional considerations, to help developers effectively integrate and tailor the progress bar's appearance within their .NET WinForms applications.

Last updated