From 45a0bd9e7db270b6c4a03a52024d3cbc8a9e7251 Mon Sep 17 00:00:00 2001 From: Eric Fu Date: Wed, 4 Jan 2023 00:05:54 +0800 Subject: [PATCH 1/2] switch the logo color according to system theme --- .../Light Switch/Services/ThemeService.cs | 16 ++++++++++------ src/Light Switch/Light Switch/Storage.cs | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Light Switch/Light Switch/Services/ThemeService.cs b/src/Light Switch/Light Switch/Services/ThemeService.cs index 8a70c26..a674be1 100644 --- a/src/Light Switch/Light Switch/Services/ThemeService.cs +++ b/src/Light Switch/Light Switch/Services/ThemeService.cs @@ -43,12 +43,14 @@ public void Reload() private void SetLight() { - NotifyIcon.Icon = Resources.Icon_LightMode; - var preferences = PreferencesService.GetPreferences(); if (preferences.IsAppThemeEnabled) SetAppTheme(true); - if (preferences.IsSystemThemeEnabled) SetSystemTheme(true); + if (preferences.IsSystemThemeEnabled) + { + SetSystemTheme(true); + NotifyIcon.Icon = Resources.Icon_LightMode; + } if (preferences.IsWallpaperEnabled) { if (File.Exists(preferences.LightWallpaperPath)) @@ -66,12 +68,14 @@ private void SetLight() private void SetDark() { - NotifyIcon.Icon = Resources.Icon_DarkMode; - var preferences = PreferencesService.GetPreferences(); if (preferences.IsAppThemeEnabled) SetAppTheme(false); - if (preferences.IsSystemThemeEnabled) SetSystemTheme(false); + if (preferences.IsSystemThemeEnabled) + { + SetSystemTheme(false); + NotifyIcon.Icon = Resources.Icon_DarkMode; + } if (preferences.IsWallpaperEnabled) { if (File.Exists(preferences.DarkWallpaperPath)) diff --git a/src/Light Switch/Light Switch/Storage.cs b/src/Light Switch/Light Switch/Storage.cs index 5bfea9e..bf382d8 100644 --- a/src/Light Switch/Light Switch/Storage.cs +++ b/src/Light Switch/Light Switch/Storage.cs @@ -97,17 +97,17 @@ public bool Equals(FileInfo x, FileInfo y) _ => null, }; - public static readonly Storage Wallpapers = new(nameof(Wallpapers)); - /// /// Path to LightSwitch storage in current user's temp folder. /// private static string BasePath { get; } = Path.Combine(Path.GetTempPath(), "LightSwitch"); - /// - /// Generates a unique string from current date and time. - /// - private static string GenerateUniqueString() + public static readonly Storage Wallpapers = new(nameof(Wallpapers)); + + /// + /// Generates a unique string from current date and time. + /// + private static string GenerateUniqueString() { var now = DateTime.Now; return $"{now.Year}{now.Month}{now.Day}{now.Hour}{now.Minute}{now.Second}{now.Millisecond}"; From 15716feb44fec82d4d791d3f8511be81f8744d8b Mon Sep 17 00:00:00 2001 From: Eric Fu Date: Sun, 8 Jan 2023 10:40:39 +0800 Subject: [PATCH 2/2] fix indent --- src/Light Switch/Light Switch/Services/ThemeService.cs | 8 ++++---- src/Light Switch/Light Switch/Storage.cs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Light Switch/Light Switch/Services/ThemeService.cs b/src/Light Switch/Light Switch/Services/ThemeService.cs index a674be1..376c823 100644 --- a/src/Light Switch/Light Switch/Services/ThemeService.cs +++ b/src/Light Switch/Light Switch/Services/ThemeService.cs @@ -49,8 +49,8 @@ private void SetLight() if (preferences.IsSystemThemeEnabled) { SetSystemTheme(true); - NotifyIcon.Icon = Resources.Icon_LightMode; - } + NotifyIcon.Icon = Resources.Icon_LightMode; + } if (preferences.IsWallpaperEnabled) { if (File.Exists(preferences.LightWallpaperPath)) @@ -74,8 +74,8 @@ private void SetDark() if (preferences.IsSystemThemeEnabled) { SetSystemTheme(false); - NotifyIcon.Icon = Resources.Icon_DarkMode; - } + NotifyIcon.Icon = Resources.Icon_DarkMode; + } if (preferences.IsWallpaperEnabled) { if (File.Exists(preferences.DarkWallpaperPath)) diff --git a/src/Light Switch/Light Switch/Storage.cs b/src/Light Switch/Light Switch/Storage.cs index bf382d8..f134780 100644 --- a/src/Light Switch/Light Switch/Storage.cs +++ b/src/Light Switch/Light Switch/Storage.cs @@ -102,12 +102,12 @@ public bool Equals(FileInfo x, FileInfo y) /// private static string BasePath { get; } = Path.Combine(Path.GetTempPath(), "LightSwitch"); - public static readonly Storage Wallpapers = new(nameof(Wallpapers)); + public static readonly Storage Wallpapers = new(nameof(Wallpapers)); - /// - /// Generates a unique string from current date and time. - /// - private static string GenerateUniqueString() + /// + /// Generates a unique string from current date and time. + /// + private static string GenerateUniqueString() { var now = DateTime.Now; return $"{now.Year}{now.Month}{now.Day}{now.Hour}{now.Minute}{now.Second}{now.Millisecond}";