@@ -52,8 +52,6 @@ public class ItemViewModel : INotifyPropertyChanged, IDisposable
5252
5353 private string _jumpString = "" ;
5454 private readonly DispatcherTimer jumpTimer = new DispatcherTimer ( ) ;
55- private SortOption _directorySortOption = SortOption . Name ;
56- private SortDirection _directorySortDirection = SortDirection . Ascending ;
5755
5856 private string _customPath ;
5957
@@ -161,111 +159,82 @@ public bool IsFolderEmptyTextDisplayed
161159 }
162160 }
163161
164- public SortOption DirectorySortOption
162+ public void UpdateSortOptionStatus ( )
165163 {
166- get
167- {
168- return _directorySortOption ;
169- }
170- set
171- {
172- if ( value != _directorySortOption )
173- {
174- _directorySortOption = value ;
175- NotifyPropertyChanged ( "DirectorySortOption" ) ;
176- NotifyPropertyChanged ( "IsSortedByName" ) ;
177- NotifyPropertyChanged ( "IsSortedByDate" ) ;
178- NotifyPropertyChanged ( "IsSortedByType" ) ;
179- NotifyPropertyChanged ( "IsSortedBySize" ) ;
180- OrderFiles ( ) ;
181- }
182- }
164+ NotifyPropertyChanged ( "IsSortedByName" ) ;
165+ NotifyPropertyChanged ( "IsSortedByDate" ) ;
166+ NotifyPropertyChanged ( "IsSortedByType" ) ;
167+ NotifyPropertyChanged ( "IsSortedBySize" ) ;
168+ OrderFiles ( ) ;
183169 }
184170
185- public SortDirection DirectorySortDirection
171+ public void UpdateSortDirectionStatus ( )
186172 {
187- get
188- {
189- return _directorySortDirection ;
190- }
191- set
192- {
193- if ( value != _directorySortDirection )
194- {
195- _directorySortDirection = value ;
196- NotifyPropertyChanged ( "DirectorySortDirection" ) ;
197- NotifyPropertyChanged ( "IsSortedAscending" ) ;
198- NotifyPropertyChanged ( "IsSortedDescending" ) ;
199- OrderFiles ( ) ;
200- }
201- }
173+ NotifyPropertyChanged ( "IsSortedAscending" ) ;
174+ NotifyPropertyChanged ( "IsSortedDescending" ) ;
175+ OrderFiles ( ) ;
202176 }
203177
204178 public bool IsSortedByName
205179 {
206- get => DirectorySortOption == SortOption . Name ;
180+ get => AppSettings . DirectorySortOption == SortOption . Name ;
207181 set
208182 {
209183 if ( value )
210184 {
211- DirectorySortOption = SortOption . Name ;
185+ AppSettings . DirectorySortOption = SortOption . Name ;
212186 NotifyPropertyChanged ( "IsSortedByName" ) ;
213- NotifyPropertyChanged ( "DirectorySortOption" ) ;
214187 }
215188 }
216189 }
217190
218191 public bool IsSortedByDate
219192 {
220- get => DirectorySortOption == SortOption . DateModified ;
193+ get => AppSettings . DirectorySortOption == SortOption . DateModified ;
221194 set
222195 {
223196 if ( value )
224197 {
225- DirectorySortOption = SortOption . DateModified ;
198+ AppSettings . DirectorySortOption = SortOption . DateModified ;
226199 NotifyPropertyChanged ( "IsSortedByDate" ) ;
227- NotifyPropertyChanged ( "DirectorySortOption" ) ;
228200 }
229201 }
230202 }
231203
232204 public bool IsSortedByType
233205 {
234- get => DirectorySortOption == SortOption . FileType ;
206+ get => AppSettings . DirectorySortOption == SortOption . FileType ;
235207 set
236208 {
237209 if ( value )
238210 {
239- DirectorySortOption = SortOption . FileType ;
211+ AppSettings . DirectorySortOption = SortOption . FileType ;
240212 NotifyPropertyChanged ( "IsSortedByType" ) ;
241- NotifyPropertyChanged ( "DirectorySortOption" ) ;
242213 }
243214 }
244215 }
245216
246217 public bool IsSortedBySize
247218 {
248- get => DirectorySortOption == SortOption . Size ;
219+ get => AppSettings . DirectorySortOption == SortOption . Size ;
249220 set
250221 {
251222 if ( value )
252223 {
253- DirectorySortOption = SortOption . Size ;
224+ AppSettings . DirectorySortOption = SortOption . Size ;
254225 NotifyPropertyChanged ( "IsSortedBySize" ) ;
255- NotifyPropertyChanged ( "DirectorySortOption" ) ;
256226 }
257227 }
258228 }
259229
260230 public bool IsSortedAscending
261231 {
262- get => DirectorySortDirection == SortDirection . Ascending ;
232+ get => AppSettings . DirectorySortDirection == SortDirection . Ascending ;
263233 set
264234 {
265- DirectorySortDirection = value ? SortDirection . Ascending : SortDirection . Descending ;
235+ AppSettings . DirectorySortDirection = value ? SortDirection . Ascending : SortDirection . Descending ;
266236 NotifyPropertyChanged ( "IsSortedAscending" ) ;
267237 NotifyPropertyChanged ( "IsSortedDescending" ) ;
268- NotifyPropertyChanged ( "DirectorySortDirection" ) ;
269238 }
270239 }
271240
@@ -274,10 +243,9 @@ public bool IsSortedDescending
274243 get => ! IsSortedAscending ;
275244 set
276245 {
277- DirectorySortDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
246+ AppSettings . DirectorySortDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
278247 NotifyPropertyChanged ( "IsSortedAscending" ) ;
279248 NotifyPropertyChanged ( "IsSortedDescending" ) ;
280- NotifyPropertyChanged ( "DirectorySortDirection" ) ;
281249 }
282250 }
283251
@@ -393,7 +361,7 @@ public void OrderFiles()
393361 static object orderByNameFunc ( ListedItem item ) => item . ItemName ;
394362 Func < ListedItem , object > orderFunc = orderByNameFunc ;
395363 NaturalStringComparer naturalStringComparer = new NaturalStringComparer ( ) ;
396- switch ( DirectorySortOption )
364+ switch ( AppSettings . DirectorySortOption )
397365 {
398366 case SortOption . Name :
399367 orderFunc = orderByNameFunc ;
@@ -418,35 +386,35 @@ public void OrderFiles()
418386 IOrderedEnumerable < ListedItem > ordered ;
419387 List < ListedItem > orderedList ;
420388
421- if ( DirectorySortDirection == SortDirection . Ascending )
389+ if ( AppSettings . DirectorySortDirection == SortDirection . Ascending )
422390 {
423- if ( DirectorySortOption == SortOption . Name )
391+ if ( AppSettings . DirectorySortOption == SortOption . Name )
424392 ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenBy ( orderFunc , naturalStringComparer ) ;
425393 else
426394 ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenBy ( orderFunc ) ;
427395 }
428396 else
429397 {
430- if ( DirectorySortOption == SortOption . FileType )
398+ if ( AppSettings . DirectorySortOption == SortOption . FileType )
431399 {
432- if ( DirectorySortOption == SortOption . Name )
400+ if ( AppSettings . DirectorySortOption == SortOption . Name )
433401 ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenByDescending ( orderFunc , naturalStringComparer ) ;
434402 else
435403 ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenByDescending ( orderFunc ) ;
436404 }
437405 else
438406 {
439- if ( DirectorySortOption == SortOption . Name )
407+ if ( AppSettings . DirectorySortOption == SortOption . Name )
440408 ordered = _filesAndFolders . OrderByDescending ( folderThenFileAsync ) . ThenByDescending ( orderFunc , naturalStringComparer ) ;
441409 else
442410 ordered = _filesAndFolders . OrderByDescending ( folderThenFileAsync ) . ThenByDescending ( orderFunc ) ;
443411 }
444412 }
445413
446414 // Further order by name if applicable
447- if ( DirectorySortOption != SortOption . Name )
415+ if ( AppSettings . DirectorySortOption != SortOption . Name )
448416 {
449- if ( DirectorySortDirection == SortDirection . Ascending )
417+ if ( AppSettings . DirectorySortDirection == SortDirection . Ascending )
450418 ordered = ordered . ThenBy ( orderByNameFunc , naturalStringComparer ) ;
451419 else
452420 ordered = ordered . ThenByDescending ( orderByNameFunc , naturalStringComparer ) ;
@@ -1480,4 +1448,4 @@ public void Dispose()
14801448 CloseWatcher ( ) ;
14811449 }
14821450 }
1483- }
1451+ }
0 commit comments