Siticone Wallpaper Panel
The SiticoneWallpaperPanel is a specialized container control designed for high-fidelity background image rendering.
Unlike the standard Panel, it offers built-in opacity control for images (without affecting child controls), responsive scaling modes,
and optimized double-buffering to prevent flicker during resizing.
Key Features
Designed to solve common WinForms background image limitations.
| Feature | Description |
|---|---|
Image Opacity |
Allows fading the background image (0.0 to 1.0) to blend it with the panel's BackColor, creating subtle textures or watermarks. |
Responsive Scaling |
Includes a 'Zoom' mode that preserves aspect ratio while filling the panel, preventing image distortion common in standard controls. |
Flicker-Free |
Uses OptimizedDoubleBuffer and AllPaintingInWmPaint styles to ensure smooth resizing animations. |
Properties
Configuration options for image handling and display.
| Property | Type | Description & Usage Example |
|---|---|---|
Wallpaper |
Image |
panel.Wallpaper = Resources.Background;
The main image to display. Replaces the standard BackgroundImage property.
|
WallpaperOpacity |
float |
panel.WallpaperOpacity = 0.5f;
Controls transparency of the image only.
1.0 = Fully Opaque (Normal)
0.5 = Semi-transparent (Blends with BackColor)
0.0 = Invisible
|
WallpaperStretchMode |
Enum | panel.WallpaperStretchMode = WallpaperStretchMode.Zoom; Determines how the image is sized. See the Enumerations section below. |
BackColor |
Color |
panel.BackColor = Color.Black;
The solid color drawn behind the wallpaper. Essential when WallpaperOpacity is less than 1.0 to control the blend tint.
|
Enumerations
public enum WallpaperStretchMode
{
// Draws image at original size (0,0). Clips if too large.
None,
// Stretches image to fill panel. Distorts aspect ratio.
Stretch,
// Scales image to fit panel while keeping aspect ratio.
// Centers image automatically. Best for responsive UIs.
Zoom,
// Centers image at original size. Clips edges if too large.
Center
}
Detailed Usage Examples
Example 1: Subtle Watermark Background
Creates a professional-looking container with a faint logo in the background. Using a low opacity blends the image with the panel's white background.
private void InitializeWatermarkPanel()
{
var pnl = new SiticoneWallpaperPanel();
pnl.Dock = DockStyle.Fill;
pnl.BackColor = Color.White;
// Set the logo image
pnl.Wallpaper = Properties.Resources.CompanyLogo;
// Make it faint (15% visibility)
pnl.WallpaperOpacity = 0.15f;
// Ensure logo stays proportional and centered
pnl.WallpaperStretchMode = WallpaperStretchMode.Zoom;
this.Controls.Add(pnl);
}
Example 2: Darkened Hero Image
Often used in login screens. Sets a black background and reduces image opacity to make white text readable on top of a busy photo.
private void SetupLoginBackground()
{
heroPanel.BackColor = Color.Black; // Dark base
heroPanel.Wallpaper = Image.FromFile("cityscape.jpg");
// Darken image by showing 60% image, 40% black background
heroPanel.WallpaperOpacity = 0.6f;
// Fill the entire space, potentially cropping edges to maintain ratio
// Note: Zoom fits *inside*. To fill *outside* (Crop), use logic or custom paint.
// Here we use Stretch for full coverage if ratio is close.
heroPanel.WallpaperStretchMode = WallpaperStretchMode.Stretch;
}
Example 3: Interactive Opacity Slider
Dynamically changing opacity at runtime based on user input (e.g., a slider control).
private void trackBarOpacity_Scroll(object sender, EventArgs e)
{
// Convert slider value (0-100) to float (0.0-1.0)
float opacity = trackBarOpacity.Value / 100f;
// Update panel immediately (triggers repaint)
siticoneWallpaperPanel1.WallpaperOpacity = opacity;
lblOpacityValue.Text = $"Opacity: {opacity:P0}";
}