From e6ccb7324f6d141e06561731c4d2c5ea92e24246 Mon Sep 17 00:00:00 2001 From: Lann <8305632+Lann094@users.noreply.github.com> Date: Fri, 7 Aug 2026 21:41:16 +1000 Subject: [PATCH] Add dark theme --- .../ProjectLocales.Designer.cs | 11 +++- .../ProjectLocales.de.resx | 12 +++++ .../ProjectLocales.resx | 12 +++++ Source/AutoActions/App.xaml | 4 +- Source/AutoActions/App.xaml.cs | 27 +++++++++- Source/AutoActions/AutoActions.csproj | 13 ++--- Source/AutoActions/Controls/1_Colors.xaml | 40 -------------- ...ltControls.xaml => 1_DefaultControls.xaml} | 12 +++-- ...tomComboBox.xaml => 2_CustomComboBox.xaml} | 4 +- Source/AutoActions/Controls/AppResources.xaml | 52 ++++--------------- Source/AutoActions/Theming/DarkColors.xaml | 43 +++++++++++++++ Source/AutoActions/Theming/LightColors.xaml | 40 +++++++++++--- .../Theming/ThemeResourceDirectory.cs | 2 +- Source/AutoActions/Theming/ThemeSetting.cs | 9 ++++ Source/AutoActions/UserAppSettings.cs | 13 +++++ .../Views/ActionShortcutManagerView.xaml | 2 +- .../Views/ApplicationAdderView.xaml | 2 +- .../Views/AutoActionsInfoView.xaml | 2 +- .../Views/AutoActionsLicenseView.xaml | 2 +- .../Views/AutoActionsLogsView.xaml | 2 +- .../Views/AutoActionsMainView.xaml | 6 +-- .../Views/ProfileActionAdderView.xaml | 2 +- Source/AutoActions/Views/StatusView.xaml | 4 +- .../Views/UWPApplicationDialogView.xaml | 4 +- .../Views/UserAppSettingsView.xaml | 49 ++++++++++------- Source/AutoActions/WinAPIFunctions.cs | 22 ++++++++ 26 files changed, 253 insertions(+), 138 deletions(-) delete mode 100644 Source/AutoActions/Controls/1_Colors.xaml rename Source/AutoActions/Controls/{2_DefaultControls.xaml => 1_DefaultControls.xaml} (96%) rename Source/AutoActions/Controls/{3_CustomComboBox.xaml => 2_CustomComboBox.xaml} (98%) create mode 100644 Source/AutoActions/Theming/DarkColors.xaml create mode 100644 Source/AutoActions/Theming/ThemeSetting.cs diff --git a/Source/AutoActions.ProjectResources/ProjectLocales.Designer.cs b/Source/AutoActions.ProjectResources/ProjectLocales.Designer.cs index 225a533..a8fd9b3 100644 --- a/Source/AutoActions.ProjectResources/ProjectLocales.Designer.cs +++ b/Source/AutoActions.ProjectResources/ProjectLocales.Designer.cs @@ -402,7 +402,16 @@ public static string ColorDepth { return ResourceManager.GetString("ColorDepth", resourceCulture); } } - + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Theme ähnelt. + /// + public static string Theme { + get { + return ResourceManager.GetString("Theme", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die 10-Bit ähnelt. /// diff --git a/Source/AutoActions.ProjectResources/ProjectLocales.de.resx b/Source/AutoActions.ProjectResources/ProjectLocales.de.resx index e100045..f6ec053 100644 --- a/Source/AutoActions.ProjectResources/ProjectLocales.de.resx +++ b/Source/AutoActions.ProjectResources/ProjectLocales.de.resx @@ -207,6 +207,18 @@ Beim Start auf neuere Version prüfen + + Design + + + Automatisch + + + Hell + + + Dunkel + Anwendungen wählen diff --git a/Source/AutoActions.ProjectResources/ProjectLocales.resx b/Source/AutoActions.ProjectResources/ProjectLocales.resx index 1d4e8df..3da512f 100644 --- a/Source/AutoActions.ProjectResources/ProjectLocales.resx +++ b/Source/AutoActions.ProjectResources/ProjectLocales.resx @@ -217,6 +217,18 @@ Check for new version on startup + + Theme + + + Auto + + + Light + + + Dark + Choose application diff --git a/Source/AutoActions/App.xaml b/Source/AutoActions/App.xaml index c8c1e11..a74f5c5 100644 --- a/Source/AutoActions/App.xaml +++ b/Source/AutoActions/App.xaml @@ -19,6 +19,8 @@ + @@ -49,7 +51,7 @@ - + diff --git a/Source/AutoActions/App.xaml.cs b/Source/AutoActions/App.xaml.cs index b689eb1..1a0f5e1 100644 --- a/Source/AutoActions/App.xaml.cs +++ b/Source/AutoActions/App.xaml.cs @@ -30,8 +30,10 @@ public static void Main() if (mutex.WaitOne(TimeSpan.Zero, true)) { var application = new App(); - application.InitializeComponent(); + // Resolve the theme before InitializeComponent() so App.xaml merges the matching palette. Globals.Instance.LoadSettings(); + Theme = ResolveTheme(Globals.Instance.Settings.ThemeSetting); + application.InitializeComponent(); application.Run(); } else @@ -43,11 +45,34 @@ public static void Main() protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); + // Dark theme: darken the native title bar of every window (main, dialogs, splash) as it loads. + if (App.Theme == Theme.Dark) + EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(OnAnyWindowLoaded)); Views.AutoActionsMainView mainView = new Views.AutoActionsMainView(); if (!Globals.Instance.Settings.StartMinimizedToTray) mainView.Show(); } + private static void OnAnyWindowLoaded(object sender, RoutedEventArgs e) + { + if (sender is Window window) + WinAPIFunctions.SetWindowDarkMode(window, true); + } + + private static Theme ResolveTheme(ThemeSetting setting) + { + switch (setting) + { + case ThemeSetting.Light: + return Theme.Light; + case ThemeSetting.Dark: + return Theme.Dark; + default: + return AutoActions.Windows.UI.GetWindowsTheme() == AutoActions.Windows.WindowsTheme.Dark + ? Theme.Dark : Theme.Light; + } + } + protected override void OnExit(ExitEventArgs e) { if (mutex.WaitOne(TimeSpan.Zero, true)) diff --git a/Source/AutoActions/AutoActions.csproj b/Source/AutoActions/AutoActions.csproj index eb92c32..05e1fc1 100644 --- a/Source/AutoActions/AutoActions.csproj +++ b/Source/AutoActions/AutoActions.csproj @@ -302,6 +302,7 @@ + @@ -382,19 +383,15 @@ - - Designer - XamlIntelliSenseFileGenerator - XamlIntelliSenseFileGenerator Designer - + Designer XamlIntelliSenseFileGenerator - + Designer XamlIntelliSenseFileGenerator @@ -402,6 +399,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Source/AutoActions/Controls/1_Colors.xaml b/Source/AutoActions/Controls/1_Colors.xaml deleted file mode 100644 index 3a2f2e9..0000000 --- a/Source/AutoActions/Controls/1_Colors.xaml +++ /dev/null @@ -1,40 +0,0 @@ - - #2ac987 - #ff6666 - #fa8e8e - #e36b6b - - White - #fca9a9 - #FFDDDDDD - White - #FFCCCCCC - #d4d4d4 - #FF444444 - #cfcfcf - #8A8A8A - - #adadad - - - - - - - - - - - - #ad7b7b - #757575 - #969696 - #a1a1a1 - - - - - - - \ No newline at end of file diff --git a/Source/AutoActions/Controls/2_DefaultControls.xaml b/Source/AutoActions/Controls/1_DefaultControls.xaml similarity index 96% rename from Source/AutoActions/Controls/2_DefaultControls.xaml rename to Source/AutoActions/Controls/1_DefaultControls.xaml index f3328d7..8742a36 100644 --- a/Source/AutoActions/Controls/2_DefaultControls.xaml +++ b/Source/AutoActions/Controls/1_DefaultControls.xaml @@ -51,18 +51,18 @@