2
2
// Licensed under the MIT License.
3
3
4
4
using Microsoft . UI . Xaml ;
5
+ using Microsoft . UI . Xaml . Controls ;
5
6
using Microsoft . UI . Xaml . Input ;
6
7
using Microsoft . UI . Xaml . Media ;
7
8
using Microsoft . UI . Xaml . Media . Imaging ;
8
9
using Microsoft . UI . Xaml . Navigation ;
9
10
using System . Windows . Input ;
10
11
using Windows . System ;
11
- using Microsoft . UI . Xaml . Controls ;
12
12
13
13
namespace Files . App . ViewModels
14
14
{
@@ -88,10 +88,27 @@ public Stretch AppThemeBackgroundImageFit
88
88
public float AppThemeBackgroundImageOpacity
89
89
=> AppearanceSettingsService . AppThemeBackgroundImageOpacity ;
90
90
91
- public ImageSource ? AppThemeBackgroundImageSource =>
92
- string . IsNullOrEmpty ( AppearanceSettingsService . AppThemeBackgroundImageSource )
93
- ? null
94
- : new BitmapImage ( new Uri ( AppearanceSettingsService . AppThemeBackgroundImageSource , UriKind . RelativeOrAbsolute ) ) ;
91
+ public ImageSource ? AppThemeBackgroundImageSource
92
+ {
93
+ get
94
+ {
95
+ if ( string . IsNullOrWhiteSpace ( AppearanceSettingsService . AppThemeBackgroundImageSource ) )
96
+ return null ;
97
+
98
+ if ( ! Uri . TryCreate ( AppearanceSettingsService . AppThemeBackgroundImageSource , UriKind . RelativeOrAbsolute , out Uri ? validUri ) )
99
+ return null ;
100
+
101
+ try
102
+ {
103
+ return new BitmapImage ( validUri ) ;
104
+ }
105
+ catch ( Exception )
106
+ {
107
+ // Catch potential errors
108
+ return null ;
109
+ }
110
+ }
111
+ }
95
112
96
113
public VerticalAlignment AppThemeBackgroundImageVerticalAlignment
97
114
=> AppearanceSettingsService . AppThemeBackgroundImageVerticalAlignment ;
@@ -104,7 +121,7 @@ public HorizontalAlignment AppThemeBackgroundImageHorizontalAlignment
104
121
context . PageType is not ContentPageTypes . Home &&
105
122
context . PageType is not ContentPageTypes . ReleaseNotes &&
106
123
context . PageType is not ContentPageTypes . Settings ;
107
-
124
+
108
125
public bool ShowStatusBar =>
109
126
context . PageType is not ContentPageTypes . Home &&
110
127
context . PageType is not ContentPageTypes . ReleaseNotes &&
0 commit comments