diff --git a/v9/Components/ImageGlass.Settings/Config.cs b/v9/Components/ImageGlass.Settings/Config.cs
index 21249d5ae..ef5c5c9bf 100644
--- a/v9/Components/ImageGlass.Settings/Config.cs
+++ b/v9/Components/ImageGlass.Settings/Config.cs
@@ -168,6 +168,11 @@ public static class Config
};
+ ///
+ /// Gets, sets current theme.
+ ///
+ public static IgTheme Theme { get; set; } = new();
+
#endregion
@@ -301,11 +306,6 @@ public static class Config
///
public static bool EnableWindowTopMost { get; set; } = false;
- /////
- ///// Gets, sets the direction of thumbnail bar
- /////
- //public static bool IsThumbnailHorizontal { get; set; } = true;
-
///
/// Gets, sets value indicating that Confirmation dialog is displayed when deleting image
///
@@ -646,6 +646,16 @@ public static class Config
///
public static string LastSeenImagePath { get; set; } = "";
+ ///
+ /// Gets, sets the theme name for dark mode.
+ ///
+ public static string DarkTheme { get; set; } = "";
+
+ ///
+ /// Gets, sets the theme name for light mode.
+ ///
+ public static string LightTheme { get; set; } = "";
+
/////
///// Gets, sets the absolute file path of the exiftool executable file
/////
@@ -760,7 +770,7 @@ public static class Config
///
public static BackdropStyle WindowBackdrop { get; set; } = BackdropStyle.Mica;
- #endregion
+ #endregion // Enum items
#region Other types items
@@ -780,21 +790,15 @@ public static class Config
///
public static IgLang Language { get; set; }
- ///
- /// Gets, sets theme
- ///
- public static IgTheme Theme { get; set; }
-
///
/// Gets, sets layout for FrmMain. Syntax:
/// Dictionary["ControlName", "DockStyle;order"]
///
public static Dictionary Layout { get; set; } = new();
- #endregion
-
- #endregion
+ #endregion // Other types items
+ #endregion // Setting items
@@ -836,7 +840,6 @@ public static void Load()
ShowCheckerBoard = items.GetValue(nameof(ShowCheckerBoard), ShowCheckerBoard);
EnableMultiInstances = items.GetValue(nameof(EnableMultiInstances), EnableMultiInstances);
EnableWindowTopMost = items.GetValue(nameof(EnableWindowTopMost), EnableWindowTopMost);
- //IsThumbnailHorizontal = items.GetValue(nameof(IsThumbnailHorizontal), IsThumbnailHorizontal);
ShowDeleteConfirmation = items.GetValue(nameof(ShowDeleteConfirmation), ShowDeleteConfirmation);
ShowSaveOverrideConfirmation = items.GetValue(nameof(ShowSaveOverrideConfirmation), ShowSaveOverrideConfirmation);
//IsScrollbarsVisible = items.GetValue(nameof(IsScrollbarsVisible), IsScrollbarsVisible);
@@ -960,6 +963,9 @@ public static void Load()
AutoUpdate = items.GetValue(nameof(AutoUpdate), AutoUpdate);
LastSeenImagePath = items.GetValue(nameof(LastSeenImagePath), LastSeenImagePath);
+ DarkTheme = items.GetValue(nameof(DarkTheme), DarkTheme);
+ LightTheme = items.GetValue(nameof(LightTheme), LightTheme);
+
//ExifToolExePath = items.GetValue(nameof(ExifToolExePath), ExifToolExePath);
//ExifToolCommandArgs = items.GetValue(nameof(ExifToolCommandArgs), ExifToolCommandArgs);
@@ -1051,31 +1057,7 @@ public static void Load()
#endregion
- #region Theme
- var themeFolderName = items.GetValue(nameof(Theme), Constants.DEFAULT_THEME);
- var th = new IgTheme(App.ConfigDir(PathType.Dir, Dir.Themes, themeFolderName));
-
- if (th.IsValid)
- {
- Theme = th;
- }
- else
- {
- // load default theme
- Theme = new(App.StartUpDir(Dir.Themes, Constants.DEFAULT_THEME));
- }
-
- if (!Theme.IsValid)
- {
- throw new InvalidDataException($"Unable to load '{th.FolderName}' theme pack. " +
- $"Please make sure '{th.FolderName}\\{IgTheme.CONFIG_FILE}' file is valid.");
- }
-
- Theme.ReloadThemeColors();
- #endregion
-
-
- // must load after Theme
+ // must load before Theme
#region BackgroundColor
var bgValue = items.GetValue(nameof(BackgroundColor), string.Empty);
@@ -1091,6 +1073,10 @@ public static void Load()
#endregion
+ // load theme
+ LoadThemePack(WinColorsApi.IsDarkMode, true, true);
+
+
#region SlideshowBackgroundColor
bgValue = items.GetValue(nameof(SlideshowBackgroundColor), string.Empty);
@@ -1109,6 +1095,71 @@ public static void Load()
}
+ ///
+ /// Loads theme pack and only theme colors.
+ ///
+ ///
+ /// Determine which theme should be loaded: or .
+ ///
+ ///
+ /// If theme pack is invalid, should load the default theme pack ?
+ ///
+ ///
+ /// If theme pack is invalid, should throw exception?
+ ///
+ ///
+ public static void LoadThemePack(bool darkMode, bool useFallBackTheme, bool throwIfThemeInvalid)
+ {
+ var themeFolderName = darkMode ? DarkTheme : LightTheme;
+ if (string.IsNullOrEmpty(themeFolderName))
+ {
+ themeFolderName = Constants.DEFAULT_THEME;
+ }
+
+ var th = new IgTheme(App.ConfigDir(PathType.Dir, Dir.Themes, themeFolderName));
+
+ if (!th.IsValid)
+ {
+ if (useFallBackTheme)
+ {
+ th.Dispose();
+ th = null;
+
+ // load default theme
+ th = new(App.StartUpDir(Dir.Themes, Constants.DEFAULT_THEME));
+ }
+ }
+
+ if (!th.IsValid && throwIfThemeInvalid)
+ {
+ th.Dispose();
+ th = null;
+
+ throw new InvalidDataException($"Unable to load '{th.FolderName}' theme pack. " +
+ $"Please make sure '{th.FolderName}\\{IgTheme.CONFIG_FILE}' file is valid.");
+ }
+
+ // update the name of dark/light theme
+ if (darkMode) DarkTheme = th.FolderName;
+ else LightTheme = th.FolderName;
+
+
+ // load theme colors
+ th.ReloadThemeColors();
+
+ // load background color
+ if (Config.BackgroundColor == Theme.Colors.BgColor)
+ {
+ Config.BackgroundColor = th.Colors.BgColor;
+ }
+
+
+ // set to the current theme
+ Theme?.Dispose();
+ Theme = th;
+ }
+
+
///
/// Parses and writes configs to file
///
@@ -1331,7 +1382,6 @@ private static dynamic PrepareJsonSettingObjects()
settings.TryAdd(nameof(ShowCheckerBoard), ShowCheckerBoard);
settings.TryAdd(nameof(EnableMultiInstances), EnableMultiInstances);
settings.TryAdd(nameof(EnableWindowTopMost), EnableWindowTopMost);
- //settings.TryAdd(nameof(IsThumbnailHorizontal), IsThumbnailHorizontal);
settings.TryAdd(nameof(ShowDeleteConfirmation), ShowDeleteConfirmation);
settings.TryAdd(nameof(ShowSaveOverrideConfirmation), ShowSaveOverrideConfirmation);
//settings.TryAdd(nameof(IsScrollbarsVisible), IsScrollbarsVisible);
@@ -1434,6 +1484,8 @@ private static dynamic PrepareJsonSettingObjects()
settings.TryAdd(nameof(ColorProfile), ColorProfile);
settings.TryAdd(nameof(AutoUpdate), AutoUpdate);
settings.TryAdd(nameof(LastSeenImagePath), LastSeenImagePath);
+ settings.TryAdd(nameof(DarkTheme), DarkTheme);
+ settings.TryAdd(nameof(LightTheme), LightTheme);
//settings.TryAdd(nameof(ExifToolExePath), ExifToolExePath);
//settings.TryAdd(nameof(ExifToolCommandArgs), ExifToolCommandArgs);
@@ -1445,7 +1497,6 @@ private static dynamic PrepareJsonSettingObjects()
settings.TryAdd(nameof(BackgroundColor), ThemeUtils.ColorToHex(BackgroundColor));
settings.TryAdd(nameof(SlideshowBackgroundColor), ThemeUtils.ColorToHex(SlideshowBackgroundColor));
settings.TryAdd(nameof(Language), Path.GetFileName(Language.FileName));
- settings.TryAdd(nameof(Theme), Theme.FolderName);
#endregion