Siticone Copy Button
The SiticoneCopyButton is a specialized utility control designed to streamline "Copy to Clipboard" actions.
It features a modern vector-drawn checkmark animation upon success, a built-in notification popup system, ripple effects, and seamless integration with any Windows Forms control that has a readable Text property.
Core Functionality
The essential properties needed to wire up the button to a text source.
| Property | Type | Description & Usage Example |
|---|---|---|
TargetControl |
Control |
btn.TargetControl = textBoxApiKey;
The control from which text will be copied.
The target must have a public Text property.
|
Text |
string | btn.Text = "Copy API Key"; The label displayed on the button. This text temporarily disappears during the checkmark animation. |
TooltipText |
string | btn.TooltipText = "Click to copy"; Custom tooltip text displayed when hovering over the button. |
Visual Customization
Extensive styling options for the button's appearance, shape, and color states.
| Property | Type | Description & Usage Example |
|---|---|---|
NormalFillColor |
Color | btn.NormalFillColor = Color.White; |
HoverFillColor |
Color | btn.HoverFillColor = Color.AliceBlue; |
PressedFillColor |
Color | btn.PressedFillColor = Color.LightGray; |
BorderColor |
Color | btn.BorderColor = Color.Gray; |
MakeRadial |
bool | btn.MakeRadial = true; If true, automatically adjusts corner radii to half the height, creating a perfect pill or circle shape. |
TopLeftRadius ... |
int |
btn.TopLeftRadius = 15;
Individual control over each corner radius if MakeRadial is false.
|
Success Animation (Checkmark)
Configuration for the vector checkmark that animates when text is successfully copied.
| Property | Type | Description & Usage Example |
|---|---|---|
CheckmarkColor |
Color | btn.CheckmarkColor = Color.SeaGreen; The color of the animated checkmark stroke. |
CheckmarkScale |
int | btn.CheckmarkScale = 3; Controls the overall size/thickness of the checkmark. Default is 3. Range 1-20. |
CheckmarkSizeRatio |
float | btn.CheckmarkSizeRatio = 0.13f; Size of the checkmark relative to the button width (0.05 to 0.5). |
CheckmarkAnimationSpeed |
float | btn.CheckmarkAnimationSpeed = 0.05f; Controls how fast the checkmark draws itself. |
CheckmarkDisplayDurationInSeconds |
int | btn.CheckmarkDisplayDurationInSeconds = 4; How long the checkmark remains visible before reverting to the original text. |
Notification System
The control includes a built-in, non-blocking notification form (toast) that appears near the button on success. You can fully customize its appearance and typography.
| Property | Type | Description & Usage Example |
|---|---|---|
NotificationTitle |
string | btn.NotificationTitle = "Success"; |
NotificationText |
string | btn.NotificationText = "Text copied!"; |
NotificationDuration |
int | btn.NotificationDuration = 3000; Duration in milliseconds the notification popup stays visible. |
NotificationBackColor |
Color | btn.NotificationBackColor = Color.Black; |
NotificationTextColor |
Color | btn.NotificationTextColor = Color.White; |
NotificationTitleFont |
Font | btn.NotificationTitleFont = new Font("Arial", 10, FontStyle.Bold); Font used for the notification header. |
NotificationTextFont |
Font | btn.NotificationTextFont = new Font("Arial", 9); Font used for the notification body text. |
Context Menu
Right-click support for accessibility and alternative interaction.
| Property | Type | Description & Usage Example |
|---|---|---|
EnableContextMenu |
bool | btn.EnableContextMenu = true; Enables a right-click menu with a "Copy to Clipboard" option. |
ContextMenuCopyText |
string | btn.ContextMenuCopyText = "Copy Code"; Customizes the text inside the right-click menu. |
ContextMenuFont |
Font | btn.ContextMenuFont = new Font("Arial", 10); Sets the font for the context menu items. |
Accessibility
Properties to ensure the control is accessible to screen readers and keyboard users.
| Property | Type | Description & Usage Example |
|---|---|---|
ShowFocusCue |
bool | btn.ShowFocusCue = true; Draws a dotted line inside the border when the button has keyboard focus. |
AccessibilityName |
string | btn.AccessibilityName = "Copy API Key"; The name announced by screen readers. |
AccessibilityDescription |
string | btn.AccessibilityDescription = "Copies the API key to clipboard."; Detailed description for accessibility tools. |
AccessibilityHint |
string | btn.AccessibilityHint = "Press Enter to copy."; Instructional hint for screen reader users. |
Performance & Effects
Settings to control animations and rendering performance.
| Property | Type | Description & Usage Example |
|---|---|---|
UltraFastPerformance |
bool | btn.UltraFastPerformance = true; Important: If true, disables all smooth animations (Ripple, Color Fade, Animated Checkmark) for instant feedback. Recommended for usage in DataGrids or lists. |
RippleExpandRate |
float | btn.RippleExpandRate = 2.0f; Speed of the click ripple effect. |
ColorTransitionSpeed |
float | btn.ColorTransitionSpeed = 0.15f; Speed of fading between Normal, Hover, and Pressed colors. |
Public Methods
// Programmatically triggers the copy operation.
// This executes the copy logic, shows the animation, and displays the notification
// just as if the user had clicked the mouse.
siticoneCopyButton1.PerformClick();
// Returns an array of all controls in the parent container that have a
// readable 'Text' property. Useful for populating configuration UIs.
Control[] targets = siticoneCopyButton1.GetValidTargetControls();
foreach (var c in targets)
{
Console.WriteLine(c.Name);
}
Usage Examples
Example 1: Basic API Key Copy
Connects a copy button to a TextBox containing an API key. Uses the default "Modern" look with a pill shape.
private void InitializeCopyButton()
{
var btn = new SiticoneCopyButton();
// 1. Logic
btn.TargetControl = txtApiKey; // The TextBox to read from
btn.Text = "Copy Key";
// 2. Visuals (Pill Shape)
btn.Size = new Size(120, 35);
btn.MakeRadial = true;
btn.NormalFillColor = Color.WhiteSmoke;
btn.BorderColor = Color.LightGray;
this.Controls.Add(btn);
}
Example 2: Custom Notification Styling
Customizes the success popup to match a dark theme application.
private void SetupDarkCopy()
{
var btn = new SiticoneCopyButton();
btn.TargetControl = lblCodeSnippet;
// Customize the toast popup
btn.NotificationBackColor = Color.FromArgb(40, 40, 40);
btn.NotificationTextColor = Color.White;
btn.NotificationTitle = "Snippet Copied";
btn.NotificationText = "Code is now in your clipboard.";
// Customize the font
btn.NotificationTitleFont = new Font("Segoe UI", 11, FontStyle.Bold);
this.Controls.Add(btn);
}
Example 3: Silent/Subtle Feedback
Configures the button for a minimal interface where a popup notification is intrusive. Instead, it relies solely on the checkmark animation inside the button.
private void SetupSilentButton()
{
var btn = new SiticoneCopyButton();
btn.TargetControl = txtPassword;
// Disable the external popup form
btn.NotificationDuration = 0;
// Make the internal checkmark prominent and fast
btn.CheckmarkColor = Color.LimeGreen;
btn.CheckmarkScale = 4;
btn.CheckmarkAnimationSpeed = 0.1f; // Fast draw
// Show checkmark for only 1.5 seconds
btn.CheckmarkDisplayDurationInSeconds = 1;
this.Controls.Add(btn);
}
Example 4: Ultra-Fast Mode (DataGrid Scenario)
When using copy buttons inside a DataGridView or a long list, animations can cause lag.
UltraFastPerformance disables the animations for instant execution.
private void AddGridCopyButton(Control target)
{
var btn = new SiticoneCopyButton();
// Enable Performance Mode
btn.UltraFastPerformance = true;
btn.TargetControl = target;
btn.Text = "Copy";
btn.Size = new Size(60, 25);
btn.MakeRadial = false;
btn.TopLeftRadius = 4; // Small corner radius
this.flowLayoutPanel1.Add(btn);
}
Example 5: Full Accessibility Setup
Properly configuring the control for screen readers by setting accessible names, descriptions, and enabling focus cues.
private void SetupAccessibleButton()
{
var btn = new SiticoneCopyButton();
btn.TargetControl = txtLicenseKey;
// 1. Enable visual focus indication (dotted line)
btn.ShowFocusCue = true;
// 2. Screen Reader Properties
btn.AccessibilityName = "Copy License Key";
btn.AccessibilityDescription = "Copies the license key from the text box to your clipboard.";
btn.AccessibilityHint = "Press Space or Enter to copy.";
// 3. Standard Tab Navigation
btn.TabStop = true;
btn.TabIndex = 0;
this.Controls.Add(btn);
}
Example 6: Advanced Font Styling
Demonstrates how to change the fonts for both the notification popup and the right-click context menu to match a specific UI theme.
private void SetupStyledFonts()
{
var btn = new SiticoneCopyButton();
// 1. Notification Fonts
// Large, Serif font for the title
btn.NotificationTitleFont = new Font("Georgia", 12, FontStyle.Bold);
// Monospace for the message body
btn.NotificationTextFont = new Font("Consolas", 10, FontStyle.Regular);
// 2. Context Menu Font
// Modern sans-serif for the right-click menu
btn.ContextMenuFont = new Font("Segoe UI Light", 11);
this.Controls.Add(btn);
}
Example 7: Dynamic Target Selection
Uses the GetValidTargetControls method to automatically find and assign a target control at runtime, useful for dynamic forms.
private void AutoAssignTarget()
{
var btn = new SiticoneCopyButton();
this.Controls.Add(btn);
// Get all valid targets in the parent container
Control[] potentialTargets = btn.GetValidTargetControls();
// Logic to find a specific text box, e.g., the first one starting with "txtResult"
var resultBox = potentialTargets.FirstOrDefault(c => c.Name.StartsWith("txtResult"));
if (resultBox != null)
{
btn.TargetControl = resultBox;
btn.Text = "Copy Result";
}
else
{
btn.Enabled = false;
btn.TooltipText = "No target found";
}
}