| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System.Windows;
- using System.Windows.Media;
- namespace LocalhostMES.Core
- {
- public enum ThemeMode
- {
- Light,
- Dark
- }
- public static class ThemeManager
- {
- public static ThemeMode CurrentTheme { get; private set; } = ThemeMode.Light;
- public static void ApplyTheme(ThemeMode mode)
- {
- var app = Application.Current;
- if (app == null)
- {
- return;
- }
- CurrentTheme = mode;
- if (mode == ThemeMode.Dark)
- {
- SetBrush(app, "Win11WindowBrush", "#0F1115");
- SetBrush(app, "Win11CardBrush", "#1A1D24");
- SetBrush(app, "Win11BorderBrush", "#2C3340");
- SetBrush(app, "Win11PrimaryBrush", "#3B82F6");
- SetBrush(app, "Win11PrimaryHoverBrush", "#2563EB");
- SetBrush(app, "Win11TextBrush", "#E5E7EB");
- SetBrush(app, "Win11SubTextBrush", "#9CA3AF");
- SetBrush(app, "Win11DangerBrush", "#EF4444");
- SetBrush(app, "Win11SuccessBrush", "#22C55E");
- }
- else
- {
- SetBrush(app, "Win11WindowBrush", "#F5F6F8");
- SetBrush(app, "Win11CardBrush", "#FFFFFF");
- SetBrush(app, "Win11BorderBrush", "#DEE2E8");
- SetBrush(app, "Win11PrimaryBrush", "#2563EB");
- SetBrush(app, "Win11PrimaryHoverBrush", "#1D4ED8");
- SetBrush(app, "Win11TextBrush", "#111827");
- SetBrush(app, "Win11SubTextBrush", "#6B7280");
- SetBrush(app, "Win11DangerBrush", "#DC2626");
- SetBrush(app, "Win11SuccessBrush", "#16A34A");
- }
- }
- private static void SetBrush(Application app, string key, string colorHex)
- {
- app.Resources[key] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(colorHex));
- }
- }
- }
|