Corner and Shape Config

This feature allows developers to adjust the curvature of each corner of the control to achieve the desired shape and rounded appearance.

Overview

The Corner and Shape Customization feature provides control over the individual radii of each corner of the SiticoneContainer. Developers can specify the radius for the top-left, top-right, bottom-left, and bottom-right corners to create either subtle curves or more pronounced rounded edges.


Key Points

Property
Description
Default Value

TopLeftRadius

Radius of the top-left corner.

20

TopRightRadius

Radius of the top-right corner.

20

BottomLeftRadius

Radius of the bottom-left corner.

20

BottomRightRadius

Radius of the bottom-right corner.

20


Best Practices

Practice
Description

Uniform corner radii for consistency

Using the same radius for all corners creates a balanced, modern look that is visually pleasing.

Asymmetrical design for emphasis

Adjust one or two corner radii to be different for creating a unique or attention-catching design element.

Ensure radii values are non-negative

Always set corner radii to zero or positive values to avoid rendering issues.

Test various sizes

Experiment with different radius values in combination with control sizes to verify that the curves are proportionate.


Common Pitfalls

Pitfall
Description
Recommendation

Inconsistent radii values

Different radii on each corner may result in a disjointed appearance if not intended by design.

Carefully plan your design; use uniform values unless a special effect is needed.

Setting negative values

Negative values for corner radii can cause unexpected rendering behavior.

Validate values to ensure they are zero or greater.

Overly large radii relative to control dimensions

Excessive rounding can distort the intended rectangular shape of the control.

Ensure that the radius does not exceed half the width or height of the control.


Usage Scenarios

Scenario
Description
Example Use Case

Standard Rounded Panels

Creating a modern UI with panels featuring uniformly rounded corners.

Use the same radius value (e.g., 20) for all four corners.

Custom-Shaped Cards

Designing cards or containers with a mix of rounded and square corners to add visual interest.

Set different radii, for instance, 20 for top corners and 5 for bottom corners.

Dynamic Shape Adjustments

Adjusting the corner radii at runtime based on user preferences or adaptive layout designs.

Programmatically update the radii when the control is resized or a theme is applied.


Code Examples

Example 1: Uniform Rounded Corners

This example demonstrates how to create a SiticoneContainer control with all four corners set to the same rounded value.

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

public class MainForm : Form
{
    public MainForm()
    {
        // Create an instance of the SiticoneContainer control
        SiticoneContainer container = new SiticoneContainer
        {
            Size = new Size(300, 200),
            Location = new Point(10, 10),
            // Set the same radius for all corners for a uniform rounded look
            TopLeftRadius = 20,
            TopRightRadius = 20,
            BottomLeftRadius = 20,
            BottomRightRadius = 20
        };

        // Add the container to the form
        this.Controls.Add(container);
    }

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

Example 2: Asymmetrical Corner Customization

In this example, different radius values are applied to each corner to create a unique visual effect.

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

public class CustomCornerForm : Form
{
    public CustomCornerForm()
    {
        // Create an instance of the SiticoneContainer control with asymmetric corner radii
        SiticoneContainer container = new SiticoneContainer
        {
            Size = new Size(300, 200),
            Location = new Point(15, 15),
            // Apply custom radii for each corner
            TopLeftRadius = 30,
            TopRightRadius = 10,
            BottomLeftRadius = 5,
            BottomRightRadius = 25
        };

        // Add the container to the form
        this.Controls.Add(container);
    }

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

Example 3: Dynamic Corner Radius Adjustment

This example shows how to update the corner radii dynamically based on a user interaction, such as clicking a button.

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

public class DynamicCornerForm : Form
{
    private SiticoneContainer container;
    private Button adjustButton;

    public DynamicCornerForm()
    {
        container = new SiticoneContainer
        {
            Size = new Size(300, 200),
            Location = new Point(20, 20),
            TopLeftRadius = 20,
            TopRightRadius = 20,
            BottomLeftRadius = 20,
            BottomRightRadius = 20
        };

        adjustButton = new Button
        {
            Text = "Adjust Corners",
            Location = new Point(20, 240)
        };

        adjustButton.Click += AdjustButton_Click;

        this.Controls.Add(container);
        this.Controls.Add(adjustButton);
    }

    private void AdjustButton_Click(object sender, EventArgs e)
    {
        // Change corner radii dynamically on button click
        container.TopLeftRadius = 10;
        container.TopRightRadius = 30;
        container.BottomLeftRadius = 30;
        container.BottomRightRadius = 10;
    }

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

Review

Aspect
Notes

Flexibility

Allows for both uniform and asymmetrical rounding, giving designers the flexibility to craft unique UIs.

Ease of Customization

Simple property assignments make it easy to adjust the shape either at design time or runtime.

Integration

Seamlessly integrates with other customization features of the control, such as border and shadow effects.


Summary

The Corner and Shape Customization feature enables developers to define the curvature of each corner of the SiticoneContainer control individually. Whether aiming for a modern, uniform look or a unique asymmetrical design, this feature provides the flexibility to tailor the control’s appearance to match any UI requirement.


Additional Tips

Tip
Explanation

Use the designer for quick iterations

Leverage Visual Studio’s designer to quickly adjust and preview corner radii for the desired effect.

Combine with other visual effects

Integrate rounded corners with gradient backgrounds and border styling to create a cohesive and modern UI.

Consider control dimensions

Ensure that the chosen radii values are proportionate to the control’s size to avoid disproportionate rounding.

This comprehensive documentation should assist developers in effectively integrating and customizing the Corner and Shape Customization feature of the SiticoneContainer control in their .NET WinForms applications.

Last updated