Skip to content

Commit 05bd0a0

Browse files
committed
Fix
1 parent 884965f commit 05bd0a0

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

Bloxstrap/Integrations/AppBackgroundService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ public enum BackgroundType
2323
Extra = 3
2424
}
2525

26+
27+
2628
/// <summary>
2729
/// Get wallpaper image source berdasarkan tipe
2830
/// </summary>
2931
private static BitmapImage? GetBackgroundImage(BackgroundType type)
3032
{
3133
try
3234
{
33-
string wallpaperPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Wallpapers");
35+
string wallpaperPath = Paths.ResolveWallpapersDir();
3436

3537
string imagePath = type switch
3638
{
@@ -102,7 +104,7 @@ public static bool ValidateBackgroundFiles()
102104

103105
foreach (BackgroundType type in Enum.GetValues(typeof(BackgroundType)))
104106
{
105-
string wallpaperPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Wallpapers");
107+
string wallpaperPath = Paths.ResolveWallpapersDir();
106108
string imagePath = type switch
107109
{
108110
BackgroundType.Default => Path.Combine(wallpaperPath, "wallpapers.jpg"),

Bloxstrap/Integrations/WallpaperService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ public enum WallpaperType
3030
Quality = 2
3131
}
3232

33-
/// <summary>
34-
/// Get wallpaper path berdasarkan tipe
35-
/// </summary>
3633
private static string GetWallpaperPath(WallpaperType type)
3734
{
38-
string wallpaperPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Wallpapers");
35+
string wallpaperPath = Paths.ResolveWallpapersDir();
3936

4037
return type switch
4138
{

Bloxstrap/Paths.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ static class Paths
3939

4040
public static bool Initialized => !String.IsNullOrEmpty(Base);
4141

42+
/// <summary>
43+
/// Resolve the Wallpapers folder path, trying multiple base directories
44+
/// to handle different execution contexts (build, installed, published).
45+
/// </summary>
46+
public static string ResolveWallpapersDir()
47+
{
48+
string[] candidates = new[]
49+
{
50+
AppDomain.CurrentDomain.BaseDirectory,
51+
Path.GetDirectoryName(typeof(Paths).Assembly.Location) ?? "",
52+
Path.GetDirectoryName(Environment.ProcessPath ?? "") ?? ""
53+
};
54+
55+
foreach (string dir in candidates)
56+
{
57+
if (string.IsNullOrEmpty(dir)) continue;
58+
string path = Path.Combine(dir, "Resources", "Wallpapers");
59+
if (Directory.Exists(path)) return path;
60+
}
61+
62+
return Path.Combine(candidates[0], "Resources", "Wallpapers");
63+
}
64+
4265
public static void Initialize(string baseDirectory)
4366
{
4467
Base = baseDirectory;

0 commit comments

Comments
 (0)