Siticone Ellipse Component
The SiticoneEllipse is a powerful, non-visual component that allows you to apply smooth, rounded corners to any Windows Forms control or Form.
Instead of creating custom controls for every rounded element, you can simply drop this component onto your form and target Panels, Buttons, PictureBoxes, or the Form itself.
It utilizes GDI+ regions to clip the corners of the target control, ensuring high-performance rendering.
Core Configuration
Properties to define the target and the intensity of the rounding effect.
| Property | Type | Description & Usage Example |
|---|---|---|
TargetControl |
Control | siticoneEllipse1.TargetControl = panel1; The UI element (Button, Panel, Form, etc.) that will have its corners rounded. |
CornerRadius |
int | siticoneEllipse1.CornerRadius = 25; The radius of the rounded corners in pixels. Higher values create a smoother, more circular curve. |
EnableRounding |
bool | siticoneEllipse1.EnableRounding = true; Toggles the effect on or off. When false, the control reverts to its original rectangular shape. |
Events
Intercept the rounding process or react to target changes using the event system. Useful for dynamic UIs where controls might be resized or swapped at runtime.
// 1. Before Region Apply (Cancellable)
// Fires just before the rounded region is set on the control.
ellipse.BeforeRegionApply += (s, e) =>
{
// Example: Only apply rounding if the control is large enough
if (e.Bounds.Width < 50)
{
e.Cancel = true;
}
};
// 2. After Region Apply
// Fires immediately after the region has been applied.
ellipse.AfterRegionApply += (s, e) =>
{
Console.WriteLine("Rounded corners applied to target.");
};
// 3. Target Changing
// Fires when the TargetControl property is about to change.
ellipse.TargetControlChanging += (s, e) =>
{
// Prevent changing target if the form is busy
if (_isProcessing) e.Cancel = true;
};
Designer Experience
The component includes a Smart Tag panel in Visual Studio, allowing you to configure the `TargetControl` and `CornerRadius` directly from the design surface without writing code.
| Feature | Description |
|---|---|
Smart Tag Panel |
Click the small arrow on the component in the component tray to quickly select the Target Control and adjust the Corner Radius slider. |
Detailed Usage Examples
Example 1: Creating a Modern "Card" UI
Applying rounded corners to a standard Panel to create a modern, card-like container.
private void SetupCardPanel()
{
// Create a panel
var cardPanel = new Panel();
cardPanel.Size = new Size(300, 200);
cardPanel.BackColor = Color.White;
// Create the Ellipse component
var rounder = new SiticoneEllipse();
// Configure
rounder.CornerRadius = 20; // Smooth curves
rounder.TargetControl = cardPanel; // Apply to panel
this.Controls.Add(cardPanel);
}
Example 2: Borderless Rounded Form
Rounding the main Form itself to create a custom window shape (e.g., for a splash screen or modern app).
public MainForm()
{
InitializeComponent();
// Remove standard OS border
this.FormBorderStyle = FormBorderStyle.None;
// Initialize Ellipse
var formRounder = new SiticoneEllipse(this.components);
// Apply rounding to THIS form
formRounder.TargetControl = this;
formRounder.CornerRadius = 30;
}
Example 3: Dynamic Toggle Button
Changing the shape of a button dynamically based on user interaction.
private void BtnToggle_Click(object sender, EventArgs e)
{
// Toggle between a circle (pill) and a square
if (siticoneEllipse1.CornerRadius > 0)
{
siticoneEllipse1.CornerRadius = 0; // Make Square
btnAction.Text = "Square Mode";
}
else
{
siticoneEllipse1.CornerRadius = 25; // Make Round
btnAction.Text = "Round Mode";
}
}