@@ -52,8 +52,6 @@ public class ItemViewModel : INotifyPropertyChanged, IDisposable
52
52
53
53
private string _jumpString = "" ;
54
54
private readonly DispatcherTimer jumpTimer = new DispatcherTimer ( ) ;
55
- private SortOption _directorySortOption = SortOption . Name ;
56
- private SortDirection _directorySortDirection = SortDirection . Ascending ;
57
55
58
56
private string _customPath ;
59
57
@@ -161,111 +159,82 @@ public bool IsFolderEmptyTextDisplayed
161
159
}
162
160
}
163
161
164
- public SortOption DirectorySortOption
162
+ public void UpdateSortOptionStatus ( )
165
163
{
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 ( ) ;
183
169
}
184
170
185
- public SortDirection DirectorySortDirection
171
+ public void UpdateSortDirectionStatus ( )
186
172
{
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 ( ) ;
202
176
}
203
177
204
178
public bool IsSortedByName
205
179
{
206
- get => DirectorySortOption == SortOption . Name ;
180
+ get => AppSettings . DirectorySortOption == SortOption . Name ;
207
181
set
208
182
{
209
183
if ( value )
210
184
{
211
- DirectorySortOption = SortOption . Name ;
185
+ AppSettings . DirectorySortOption = SortOption . Name ;
212
186
NotifyPropertyChanged ( "IsSortedByName" ) ;
213
- NotifyPropertyChanged ( "DirectorySortOption" ) ;
214
187
}
215
188
}
216
189
}
217
190
218
191
public bool IsSortedByDate
219
192
{
220
- get => DirectorySortOption == SortOption . DateModified ;
193
+ get => AppSettings . DirectorySortOption == SortOption . DateModified ;
221
194
set
222
195
{
223
196
if ( value )
224
197
{
225
- DirectorySortOption = SortOption . DateModified ;
198
+ AppSettings . DirectorySortOption = SortOption . DateModified ;
226
199
NotifyPropertyChanged ( "IsSortedByDate" ) ;
227
- NotifyPropertyChanged ( "DirectorySortOption" ) ;
228
200
}
229
201
}
230
202
}
231
203
232
204
public bool IsSortedByType
233
205
{
234
- get => DirectorySortOption == SortOption . FileType ;
206
+ get => AppSettings . DirectorySortOption == SortOption . FileType ;
235
207
set
236
208
{
237
209
if ( value )
238
210
{
239
- DirectorySortOption = SortOption . FileType ;
211
+ AppSettings . DirectorySortOption = SortOption . FileType ;
240
212
NotifyPropertyChanged ( "IsSortedByType" ) ;
241
- NotifyPropertyChanged ( "DirectorySortOption" ) ;
242
213
}
243
214
}
244
215
}
245
216
246
217
public bool IsSortedBySize
247
218
{
248
- get => DirectorySortOption == SortOption . Size ;
219
+ get => AppSettings . DirectorySortOption == SortOption . Size ;
249
220
set
250
221
{
251
222
if ( value )
252
223
{
253
- DirectorySortOption = SortOption . Size ;
224
+ AppSettings . DirectorySortOption = SortOption . Size ;
254
225
NotifyPropertyChanged ( "IsSortedBySize" ) ;
255
- NotifyPropertyChanged ( "DirectorySortOption" ) ;
256
226
}
257
227
}
258
228
}
259
229
260
230
public bool IsSortedAscending
261
231
{
262
- get => DirectorySortDirection == SortDirection . Ascending ;
232
+ get => AppSettings . DirectorySortDirection == SortDirection . Ascending ;
263
233
set
264
234
{
265
- DirectorySortDirection = value ? SortDirection . Ascending : SortDirection . Descending ;
235
+ AppSettings . DirectorySortDirection = value ? SortDirection . Ascending : SortDirection . Descending ;
266
236
NotifyPropertyChanged ( "IsSortedAscending" ) ;
267
237
NotifyPropertyChanged ( "IsSortedDescending" ) ;
268
- NotifyPropertyChanged ( "DirectorySortDirection" ) ;
269
238
}
270
239
}
271
240
@@ -274,10 +243,9 @@ public bool IsSortedDescending
274
243
get => ! IsSortedAscending ;
275
244
set
276
245
{
277
- DirectorySortDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
246
+ AppSettings . DirectorySortDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
278
247
NotifyPropertyChanged ( "IsSortedAscending" ) ;
279
248
NotifyPropertyChanged ( "IsSortedDescending" ) ;
280
- NotifyPropertyChanged ( "DirectorySortDirection" ) ;
281
249
}
282
250
}
283
251
@@ -393,7 +361,7 @@ public void OrderFiles()
393
361
static object orderByNameFunc ( ListedItem item ) => item . ItemName ;
394
362
Func < ListedItem , object > orderFunc = orderByNameFunc ;
395
363
NaturalStringComparer naturalStringComparer = new NaturalStringComparer ( ) ;
396
- switch ( DirectorySortOption )
364
+ switch ( AppSettings . DirectorySortOption )
397
365
{
398
366
case SortOption . Name :
399
367
orderFunc = orderByNameFunc ;
@@ -418,35 +386,35 @@ public void OrderFiles()
418
386
IOrderedEnumerable < ListedItem > ordered ;
419
387
List < ListedItem > orderedList ;
420
388
421
- if ( DirectorySortDirection == SortDirection . Ascending )
389
+ if ( AppSettings . DirectorySortDirection == SortDirection . Ascending )
422
390
{
423
- if ( DirectorySortOption == SortOption . Name )
391
+ if ( AppSettings . DirectorySortOption == SortOption . Name )
424
392
ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenBy ( orderFunc , naturalStringComparer ) ;
425
393
else
426
394
ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenBy ( orderFunc ) ;
427
395
}
428
396
else
429
397
{
430
- if ( DirectorySortOption == SortOption . FileType )
398
+ if ( AppSettings . DirectorySortOption == SortOption . FileType )
431
399
{
432
- if ( DirectorySortOption == SortOption . Name )
400
+ if ( AppSettings . DirectorySortOption == SortOption . Name )
433
401
ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenByDescending ( orderFunc , naturalStringComparer ) ;
434
402
else
435
403
ordered = _filesAndFolders . OrderBy ( folderThenFileAsync ) . ThenByDescending ( orderFunc ) ;
436
404
}
437
405
else
438
406
{
439
- if ( DirectorySortOption == SortOption . Name )
407
+ if ( AppSettings . DirectorySortOption == SortOption . Name )
440
408
ordered = _filesAndFolders . OrderByDescending ( folderThenFileAsync ) . ThenByDescending ( orderFunc , naturalStringComparer ) ;
441
409
else
442
410
ordered = _filesAndFolders . OrderByDescending ( folderThenFileAsync ) . ThenByDescending ( orderFunc ) ;
443
411
}
444
412
}
445
413
446
414
// Further order by name if applicable
447
- if ( DirectorySortOption != SortOption . Name )
415
+ if ( AppSettings . DirectorySortOption != SortOption . Name )
448
416
{
449
- if ( DirectorySortDirection == SortDirection . Ascending )
417
+ if ( AppSettings . DirectorySortDirection == SortDirection . Ascending )
450
418
ordered = ordered . ThenBy ( orderByNameFunc , naturalStringComparer ) ;
451
419
else
452
420
ordered = ordered . ThenByDescending ( orderByNameFunc , naturalStringComparer ) ;
@@ -1480,4 +1448,4 @@ public void Dispose()
1480
1448
CloseWatcher ( ) ;
1481
1449
}
1482
1450
}
1483
- }
1451
+ }
0 commit comments