WizardPalette
Centralized color palette for design-time wizards -- 30+ color slots derived from Beep theme or SystemColors fallback, with change detection for short-circuiting repaints
Overview
Namespace: TheTechIdea.Beep.Winform.Controls.Design.Server.Dialogs
Visibility: internal sealed
WizardPalette is a centralized, stable color palette for DocumentSetupWizardDialog (and any future Beep design-time wizards). The source of truth is the Beep theme system (IBeepTheme from BeepThemesManager). One snapshot is taken per wizard invocation -- there is no mid-dialog hot-swap. When the theme system is unavailable or OS High Contrast is active, falls back to SystemColors. Key methods: Refresh() (re-samples theme and rebuilds all slots) and SnapshotKey() (computes a compact hash for change detection).
Color Slots (30+)
| Group | Properties |
|---|---|
| Form | FormBack, FormSurface, Separator, FooterBack |
| Text | HeadingFore, BodyFore, MutedFore |
| Accent | Accent, AccentFore |
| Warning | WarningBack, WarningFore |
| Mode Tiles | TileBack, TileHover, TileSelected, TileBorder, TileTitleFore, TileDescFore |
| Preview Pane | PreviewBack, PreviewBorder, PreviewActiveTab, PreviewIdleTab, PreviewStrip, PreviewText, PreviewDimText, PreviewMdiSurface |
Plus metadata: Theme (IBeepTheme?), IsHighContrast (bool).
Refresh & Change Detection
Refresh() re-samples the active Beep theme and rebuilds every color slot. It returns true if any color changed since the previous snapshot, allowing callers to short-circuit unnecessary repaints. Uses SnapshotKey() to build a compact hash string from key colors for efficient comparison.
Private helpers: ResolveBeepTheme() (returns BeepThemesManager.CurrentTheme with try/catch fallback), FillFromBeepTheme() (maps all slots from IBeepTheme), FillFromSystemColors() (maps from SystemColors), MixColor(from, to, weight) (static, linear color blending for deriving hover/selected/shade variants).
SystemColors Fallback
When IsHighContrast is true or the Beep theme system is unavailable, FillFromSystemColors() maps all palette slots from SystemColors:
- FormBack / FormSurface -> Control / Window
- HeadingFore / BodyFore -> ControlText
- Separator -> ControlDark
- Accent -> Highlight
- AccentFore -> HighlightText
Examples
// Used by DocumentSetupWizardDialog:
var palette = new WizardPalette();
palette.Refresh(); // Sample current theme
// Access colors:
var tileColor = palette.TileBack;
var accentColor = palette.Accent;
var textColor = palette.BodyFore;
// Change detection:
if (palette.Refresh()) // Returns true if colors changed
{
// Repaint affected controls
modeTile.Invalidate();
previewPanel.Invalidate();
}