Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Close Button

Siticone Close Button

The SiticoneCloseButton is a comprehensive window management control. It provides a safer, more interactive alternative to the standard form close button. Features include countdown timers, safety confirmations, automatic window state persistence (saving position/size to app.config), undo capabilities, and rich visual animations.

Close Logic & Safety

Configuration for how the button handles the closing process, including delays and confirmations.

Property Type Description & Usage Example
EnableConfirmation bool closeBtn.EnableConfirmation = true; If true, displays a MessageBox asking the user to confirm before closing the form.
ConfirmationMessage string closeBtn.ConfirmationMessage = "Exit application?"; The text displayed in the confirmation dialog.
CloseCountdown int closeBtn.CloseCountdown = 5; Delay in seconds before closing. When clicked, the button displays a countdown. Set to 0 for immediate close.
MinimizeBeforeClose bool closeBtn.MinimizeBeforeClose = true; If true, the form minimizes first, then closes after a 500ms delay, creating a smoother exit transition.
EnableUndoClose bool closeBtn.EnableUndoClose = true; Hooks into the FormClosing event. If enabled, it prompts the user, allowing them to cancel the close operation at the last moment.

Window State Persistence

Built-in functionality to automatically save and restore the parent form's position and state using the application's configuration file.

Property Type Description & Usage Example
RememberWindowPosition bool closeBtn.RememberWindowPosition = true; Automatically saves the form's screen coordinates (X, Y) to app.config on close and restores them on load.
SaveWindowState bool closeBtn.SaveWindowState = true; Automatically saves the form's state (Maximized/Normal) and restores it on the next launch.

Input & Accessibility

Features for keyboard navigation and accessibility support.

Property Type Description & Usage Example
KeyboardShortcut Keys closeBtn.KeyboardShortcut = Keys.Escape; Defines a global key press that triggers the close button logic. Default is Keys.Escape.
HighContrastMode bool closeBtn.HighContrastMode = true; Forces the control to use system high-contrast colors (SystemColors.ControlText, Highlight, HotTrack) instead of custom colors.
AccessibilityDescription string closeBtn.AccessibilityDescription = "Close Window"; Sets the accessible name/description for screen readers.

Appearance & Styling

Customize the visual representation of the close symbol and button shape.

Property Type Description & Usage Example
CloseButtonStyle SiticoneCloseButtonStyle closeBtn.CloseButtonStyle = SiticoneCloseButtonStyle.Modern; The icon style:
  • Cross: Standard X
  • Modern: Circled X
  • Dot: Minimal dot
  • Power: Power symbol
  • Custom: Custom lines
IconSize int closeBtn.IconSize = 12; The size of the central symbol in pixels.
IconThickness int closeBtn.IconThickness = 2; Thickness of the lines used to draw the symbol.
CornerRadius float closeBtn.CornerRadius = 5f; Rounds the corners of the button background.
IconColor Color closeBtn.IconColor = Color.Gray;
HoverColor Color closeBtn.HoverColor = Color.Red;
PressedColor Color closeBtn.PressedColor = Color.DarkRed;

Animations & Effects

Visual feedback settings for hover, click, and idle states.

Property Type Description & Usage Example
IconAnimation CloseIconAnimation closeBtn.IconAnimation = CloseIconAnimation.Rotate; Animation on hover: Rotate, Scale, Bounce, Fade, or None.
EnablePulseEffect bool closeBtn.EnablePulseEffect = true; Activates a continuous heartbeat animation.
EnableShakeAnimation bool closeBtn.EnableShakeAnimation = true; Button shakes horizontally when clicked before closing.
EnableGlowEffect bool closeBtn.EnableGlowEffect = true; Adds an outer glow in GlowColor when hovered or pressed.
UltraFastPerformance bool closeBtn.UltraFastPerformance = true; Disables all timers and CPU-intensive animations (pulse, rotation, glow) for maximum rendering performance.

Countdown System

Configuration for the delayed close timer.

Property Type Description & Usage Example
CountdownFormat string closeBtn.CountdownFormat = "{0}s"; Format string for the number display (e.g., "Closing in {0}").
CountdownFont Font closeBtn.CountdownFont = new Font("Arial", 10); Font used to render the remaining seconds.
CountdownColor Color closeBtn.CountdownColor = Color.White; Text color of the countdown timer.

Public Methods

UndoClose()
// Manually triggers the undo logic.
// If the form was closed (and EnableUndoClose is active), this can attempt to restore state
// or fire the CloseUndone event for custom handling.
closeBtn.UndoClose();

Events

BeforeFormClose
// Fired just before the Siticone close logic begins closing the form.
// This gives you a chance to cancel the close operation based on custom logic.
closeBtn.BeforeFormClose += (sender, e) =>
{
                if (HasUnsavedChanges)
    {
        e.Cancel = true;
                ShowSaveDialog();
    }
};
CloseUndone
// Fired when EnableUndoClose is true and the user chooses to cancel the close operation via the prompt.
closeBtn.CloseUndone += (sender, e) =>
{
    statusLabel.Text = "Close cancelled by user.";
};
AnimationComplete
// Fired when a one-shot animation (like Rotate or Shake) finishes.
closeBtn.AnimationComplete += (sender, e) =>
{
                Debug.WriteLine("Animation cycle finished.");
};

Designer Support

The control includes a Smart Tag menu for rapid configuration.

Category Features
Quick Configurations One-click presets:
  • Standard Close: Basic functionality.
  • Safe Close: Adds confirmation dialog.
  • Countdown Close: Sets a 3-second timer.
  • Accessibility Setup: Enables High Contrast and Tooltips.
Themes Visual presets: Modern (Blue), Minimal (Gray), Bold (Red Power button), Danger (Red Cross), Playful (Purple Bounce).
Shape Instantly switch between Square, Rounded, or Circle geometry.

Detailed Examples

Example 1: Safe Close with Confirmation

Ensures users don't accidentally close important windows.

C# - Safe Close
public void SetupSafeClose()
{
    btnClose.EnableConfirmation = true;
    btnClose.ConfirmationMessage = "You have unsaved work. Exit anyway?";
    
                // Add visual warning cues
    btnClose.HoverColor = Color.OrangeRed;
    btnClose.EnableShakeAnimation = true;
}

Example 2: Timed Auto-Close

Implementing a "closing in..." countdown timer directly on the button.

C# - Countdown
public void SetupTimerClose()
{
    btnClose.CloseCountdown = 5; // 5 seconds delay
    btnClose.CountdownFormat = "{0}";
    btnClose.CountdownColor = Color.Red;
    btnClose.CountdownFont = new Font("Segoe UI", 12, FontStyle.Bold);
    
                // User clicks button -> Countdown starts -> Form closes after 5s
}

Example 3: Persistent Window State

Remembering where the user left the window. This requires app.config to be writable.

C# - State Persistence
public void SetupPersistence()
{
                // Automatically saves location to app.config on close
    btnClose.RememberWindowPosition = true;
    
                // Automatically saves Maximized/Normal state to app.config on close
    btnClose.SaveWindowState = true;
}

Example 4: Undo Close Functionality

Allowing the user to recover from an accidental close action.

C# - Undo Logic
public void SetupUndo()
{
    btnClose.EnableUndoClose = true;
    
                // Event triggered if user says "Yes" to "Do you want to cancel the close?"
    btnClose.CloseUndone += (sender, e) =>
    {
                MessageBox.Show("Close cancelled! Your data is safe.");
    };
}