@@ -22,16 +22,31 @@ public Preferences()
2222 if ( localSettings . Values [ "customLocationsSetting" ] . Equals ( true ) )
2323 {
2424 CustomLocationToggle . IsOn = true ;
25+
26+ DesktopL . IsEnabled = true ;
27+ DesktopL . Text = localSettings . Values [ "DesktopLocation" ] . ToString ( ) ;
28+
2529 DownloadsL . IsEnabled = true ;
30+ DownloadsL . Text = localSettings . Values [ "DownloadsLocation" ] . ToString ( ) ;
31+
2632 DocumentsL . IsEnabled = true ;
33+ DocumentsL . Text = localSettings . Values [ "DocumentsLocation" ] . ToString ( ) ;
34+
2735 PictureL . IsEnabled = true ;
36+ PictureL . Text = localSettings . Values [ "PicturesLocation" ] . ToString ( ) ;
37+
2838 MusicL . IsEnabled = true ;
39+ MusicL . Text = localSettings . Values [ "MusicLocation" ] . ToString ( ) ;
40+
2941 VideosL . IsEnabled = true ;
42+ VideosL . Text = localSettings . Values [ "VideosLocation" ] . ToString ( ) ;
43+
3044 SaveCustomL . IsEnabled = true ;
3145 }
3246 else
3347 {
3448 CustomLocationToggle . IsOn = false ;
49+ DesktopL . IsEnabled = false ;
3550 DownloadsL . IsEnabled = false ;
3651 DocumentsL . IsEnabled = false ;
3752 PictureL . IsEnabled = false ;
@@ -43,6 +58,7 @@ public Preferences()
4358 else
4459 {
4560 CustomLocationToggle . IsOn = false ;
61+ DesktopL . IsEnabled = false ;
4662 DownloadsL . IsEnabled = false ;
4763 DocumentsL . IsEnabled = false ;
4864 PictureL . IsEnabled = false ;
@@ -58,16 +74,38 @@ private void ToggleSwitch_Toggled(object sender, Windows.UI.Xaml.RoutedEventArgs
5874 if ( ( sender as ToggleSwitch ) . IsOn )
5975 {
6076 localSettings . Values [ "customLocationsSetting" ] = true ;
77+
78+ DesktopL . IsEnabled = true ;
79+ localSettings . Values [ "DesktopLocation" ] = ProHome . DesktopPath ;
80+
6181 DownloadsL . IsEnabled = true ;
82+ localSettings . Values [ "DownloadsLocation" ] = ProHome . DownloadsPath ;
83+
6284 DocumentsL . IsEnabled = true ;
85+ localSettings . Values [ "DocumentsLocation" ] = ProHome . DocumentsPath ;
86+
6387 PictureL . IsEnabled = true ;
88+ localSettings . Values [ "PicturesLocation" ] = ProHome . PicturesPath ;
89+
6490 MusicL . IsEnabled = true ;
91+ localSettings . Values [ "MusicLocation" ] = ProHome . MusicPath ;
92+
6593 VideosL . IsEnabled = true ;
94+ localSettings . Values [ "VideosLocation" ] = ProHome . VideosPath ;
95+
96+ DesktopL . Text = localSettings . Values [ "DesktopLocation" ] . ToString ( ) ;
97+ DownloadsL . Text = localSettings . Values [ "DownloadsLocation" ] . ToString ( ) ;
98+ DocumentsL . Text = localSettings . Values [ "DocumentsLocation" ] . ToString ( ) ;
99+ PictureL . Text = localSettings . Values [ "PicturesLocation" ] . ToString ( ) ;
100+ MusicL . Text = localSettings . Values [ "MusicLocation" ] . ToString ( ) ;
101+ VideosL . Text = localSettings . Values [ "VideosLocation" ] . ToString ( ) ;
102+
66103 SaveCustomL . IsEnabled = true ;
67104 }
68105 else
69106 {
70107 localSettings . Values [ "customLocationsSetting" ] = false ;
108+ DesktopL . IsEnabled = false ;
71109 DownloadsL . IsEnabled = false ;
72110 DocumentsL . IsEnabled = false ;
73111 PictureL . IsEnabled = false ;
@@ -80,12 +118,41 @@ private void ToggleSwitch_Toggled(object sender, Windows.UI.Xaml.RoutedEventArgs
80118 private async void SaveCustomL_Click ( object sender , Windows . UI . Xaml . RoutedEventArgs e )
81119 {
82120 StorageFolder newLocationSetting ;
83- if ( DownloadsL . Text != null )
121+ bool isFlawless = true ;
122+
123+ if ( ! string . IsNullOrEmpty ( DesktopL . Text ) )
124+ {
125+ try
126+ {
127+ newLocationSetting = await StorageFolder . GetFolderFromPathAsync ( DesktopL . Text ) ;
128+ localSettings . Values [ "DesktopLocation" ] = DesktopL . Text ;
129+ DesktopL . BorderBrush = new SolidColorBrush ( Colors . Black ) ;
130+ }
131+ catch ( UnauthorizedAccessException )
132+ {
133+ await ItemViewModel < Preferences > . GetCurrentSelectedTabInstance < ProHome > ( ) . permissionBox . ShowAsync ( ) ;
134+ return ;
135+ }
136+ catch ( ArgumentException )
137+ {
138+ DesktopL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
139+ isFlawless = false ;
140+ }
141+ catch ( FileNotFoundException )
142+ {
143+ DesktopL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
144+ isFlawless = false ;
145+ }
146+ }
147+
148+ if ( ! string . IsNullOrEmpty ( DownloadsL . Text ) )
84149 {
85150 try
86151 {
87152 newLocationSetting = await StorageFolder . GetFolderFromPathAsync ( DownloadsL . Text ) ;
88153 localSettings . Values [ "DownloadsLocation" ] = DownloadsL . Text ;
154+ DownloadsL . BorderBrush = new SolidColorBrush ( Colors . Black ) ;
155+
89156 }
90157 catch ( UnauthorizedAccessException )
91158 {
@@ -95,19 +162,22 @@ private async void SaveCustomL_Click(object sender, Windows.UI.Xaml.RoutedEventA
95162 catch ( ArgumentException )
96163 {
97164 DownloadsL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
165+ isFlawless = false ;
98166 }
99167 catch ( FileNotFoundException )
100168 {
101169 DownloadsL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
170+ isFlawless = false ;
102171 }
103172 }
104173
105- if ( DocumentsL . Text != null )
174+ if ( ! string . IsNullOrEmpty ( DocumentsL . Text ) )
106175 {
107176 try
108177 {
109178 newLocationSetting = await StorageFolder . GetFolderFromPathAsync ( DocumentsL . Text ) ;
110179 localSettings . Values [ "DocumentsLocation" ] = DocumentsL . Text ;
180+ DocumentsL . BorderBrush = new SolidColorBrush ( Colors . Black ) ;
111181 }
112182 catch ( UnauthorizedAccessException )
113183 {
@@ -117,19 +187,22 @@ private async void SaveCustomL_Click(object sender, Windows.UI.Xaml.RoutedEventA
117187 catch ( ArgumentException )
118188 {
119189 DocumentsL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
190+ isFlawless = false ;
120191 }
121192 catch ( FileNotFoundException )
122193 {
123194 DocumentsL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
195+ isFlawless = false ;
124196 }
125197 }
126198
127- if ( PictureL . Text != null )
199+ if ( ! string . IsNullOrEmpty ( PictureL . Text ) )
128200 {
129201 try
130202 {
131203 newLocationSetting = await StorageFolder . GetFolderFromPathAsync ( PictureL . Text ) ;
132204 localSettings . Values [ "PicturesLocation" ] = PictureL . Text ;
205+ PictureL . BorderBrush = new SolidColorBrush ( Colors . Black ) ;
133206 }
134207 catch ( UnauthorizedAccessException )
135208 {
@@ -139,19 +212,22 @@ private async void SaveCustomL_Click(object sender, Windows.UI.Xaml.RoutedEventA
139212 catch ( ArgumentException )
140213 {
141214 PictureL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
215+ isFlawless = false ;
142216 }
143217 catch ( FileNotFoundException )
144218 {
145219 PictureL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
220+ isFlawless = false ;
146221 }
147222 }
148223
149- if ( MusicL . Text != null )
224+ if ( ! string . IsNullOrEmpty ( MusicL . Text ) )
150225 {
151226 try
152227 {
153228 newLocationSetting = await StorageFolder . GetFolderFromPathAsync ( MusicL . Text ) ;
154229 localSettings . Values [ "MusicLocation" ] = MusicL . Text ;
230+ MusicL . BorderBrush = new SolidColorBrush ( Colors . Black ) ;
155231 }
156232 catch ( UnauthorizedAccessException )
157233 {
@@ -161,19 +237,22 @@ private async void SaveCustomL_Click(object sender, Windows.UI.Xaml.RoutedEventA
161237 catch ( ArgumentException )
162238 {
163239 MusicL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
240+ isFlawless = false ;
164241 }
165242 catch ( FileNotFoundException )
166243 {
167244 MusicL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
245+ isFlawless = false ;
168246 }
169247 }
170248
171- if ( VideosL . Text != null )
249+ if ( ! string . IsNullOrEmpty ( VideosL . Text ) )
172250 {
173251 try
174252 {
175253 newLocationSetting = await StorageFolder . GetFolderFromPathAsync ( VideosL . Text ) ;
176254 localSettings . Values [ "VideosLocation" ] = VideosL . Text ;
255+ VideosL . BorderBrush = new SolidColorBrush ( Colors . Black ) ;
177256 }
178257 catch ( UnauthorizedAccessException )
179258 {
@@ -183,14 +262,19 @@ private async void SaveCustomL_Click(object sender, Windows.UI.Xaml.RoutedEventA
183262 catch ( ArgumentException )
184263 {
185264 VideosL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
265+ isFlawless = false ;
186266 }
187267 catch ( FileNotFoundException )
188268 {
189269 VideosL . BorderBrush = new SolidColorBrush ( Color . FromArgb ( 255 , 255 , 0 , 0 ) ) ;
270+ isFlawless = false ;
190271 }
191272 }
192273
193- SuccessMark . Visibility = Windows . UI . Xaml . Visibility . Visible ;
274+ if ( isFlawless )
275+ {
276+ SuccessMark . Visibility = Windows . UI . Xaml . Visibility . Visible ;
277+ }
194278 }
195279 }
196280}
0 commit comments