@@ -72,38 +72,39 @@ public override async void OpenUpdateLink()
7272
7373 public override async void SetWallpaper ( string imagePath , int displayIndex )
7474 {
75- if ( displayIndex != - 1 )
75+ if ( displayIndex != - 1 || ! imagePath . StartsWith ( Environment . CurrentDirectory ) )
7676 {
7777 WallpaperApi . SetWallpaper ( imagePath , displayIndex ) ;
7878 }
7979 else
8080 {
8181 WallpaperApi . EnableTransitions ( ) ;
8282 var profileSettings = Windows . System . UserProfile . UserProfilePersonalizationSettings . Current ;
83- await profileSettings . TrySetWallpaperImageAsync ( await LoadImageFile ( imagePath ) ) ;
83+ bool result = await profileSettings . TrySetWallpaperImageAsync ( await LoadImageFile ( imagePath ) ) ;
84+ if ( ! result )
85+ {
86+ LoggingHandler . LogMessage ( "Failed to set wallpaper with UWP API: " + imagePath ) ;
87+ }
8488 }
8589 }
8690
8791 public override async void SetLockScreen ( string imagePath )
8892 {
8993 var profileSettings = Windows . System . UserProfile . UserProfilePersonalizationSettings . Current ;
90- await profileSettings . TrySetLockScreenImageAsync ( await LoadImageFile ( imagePath ) ) ;
94+ bool result = await profileSettings . TrySetLockScreenImageAsync ( await LoadImageFile ( imagePath ) ) ;
95+ if ( ! result )
96+ {
97+ LoggingHandler . LogMessage ( "Failed to set lock screen image with UWP API: " + imagePath ) ;
98+ }
9199 }
92100
93101 private static Task < Windows . Storage . StorageFile > LoadImageFile ( string imagePath )
94102 {
95- if ( imagePath . StartsWith ( Environment . CurrentDirectory ) )
96- {
97- string [ ] pathSegments = imagePath . Split ( Path . DirectorySeparatorChar ) ;
98- var uri = new Uri ( "ms-appdata:///local/themes/" +
99- Uri . EscapeDataString ( pathSegments [ pathSegments . Length - 2 ] ) + "/" +
100- Uri . EscapeDataString ( pathSegments [ pathSegments . Length - 1 ] ) ) ;
101- return Windows . Storage . StorageFile . GetFileFromApplicationUriAsync ( uri ) . AsTask ( ) ;
102- }
103- else
104- {
105- return Windows . Storage . StorageFile . GetFileFromPathAsync ( imagePath ) . AsTask ( ) ;
106- }
103+ string [ ] pathSegments = imagePath . Split ( Path . DirectorySeparatorChar ) ;
104+ var uri = new Uri ( "ms-appdata:///local/themes/" +
105+ Uri . EscapeDataString ( pathSegments [ pathSegments . Length - 2 ] ) + "/" +
106+ Uri . EscapeDataString ( pathSegments [ pathSegments . Length - 1 ] ) ) ;
107+ return Windows . Storage . StorageFile . GetFileFromApplicationUriAsync ( uri ) . AsTask ( ) ;
107108 }
108109 }
109110}
0 commit comments