@@ -13,12 +13,16 @@ public class LayoutViewModel : ObservableObject
1313
1414 public LayoutViewModel ( )
1515 {
16+ // Layout mode
1617 SelectedDefaultLayoutModeIndex = ( int ) DefaultLayoutMode ;
1718
19+ // Sorting options
1820 SelectedDefaultSortingIndex = UserSettingsService . LayoutSettingsService . DefaultSortOption == SortOption . FileTag ? FileTagSortingIndex : ( int ) UserSettingsService . LayoutSettingsService . DefaultSortOption ;
21+ SelectedDefaultSortPriorityIndex = UserSettingsService . LayoutSettingsService . DefaultSortDirectoriesAlongsideFiles ? 2 : UserSettingsService . LayoutSettingsService . DefaultSortFilesFirst ? 1 : 0 ;
22+
23+ // Grouping options
1924 SelectedDefaultGroupingIndex = UserSettingsService . LayoutSettingsService . DefaultGroupOption == GroupOption . FileTag ? FileTagGroupingIndex : ( int ) UserSettingsService . LayoutSettingsService . DefaultGroupOption ;
2025 SelectedDefaultGroupByDateUnitIndex = ( int ) UserSettingsService . LayoutSettingsService . DefaultGroupByDateUnit ;
21- SelectedDefaultSortPriorityIndex = UserSettingsService . LayoutSettingsService . DefaultSortDirectoriesAlongsideFiles ? 2 : UserSettingsService . LayoutSettingsService . DefaultSortFilesFirst ? 1 : 0 ;
2226 }
2327
2428 // Properties
@@ -38,6 +42,8 @@ public bool SyncFolderPreferencesAcrossDirectories
3842 }
3943 }
4044
45+ // Layout mode
46+
4147 public FolderLayoutModes DefaultLayoutMode
4248 {
4349 get => UserSettingsService . LayoutSettingsService . DefaultLayoutMode ;
@@ -67,53 +73,37 @@ public int SelectedDefaultLayoutModeIndex
6773 }
6874
6975
76+ // Sorting options
7077
71- public bool SortInDescendingOrder
78+ private int selectedDefaultSortingIndex ;
79+ public int SelectedDefaultSortingIndex
7280 {
73- get => UserSettingsService . LayoutSettingsService . DefaultDirectorySortDirection == SortDirection . Descending ;
81+ get => selectedDefaultSortingIndex ;
7482 set
7583 {
76- if ( value != ( UserSettingsService . LayoutSettingsService . DefaultDirectorySortDirection == SortDirection . Descending ) )
84+ if ( SetProperty ( ref selectedDefaultSortingIndex , value ) )
7785 {
78- UserSettingsService . LayoutSettingsService . DefaultDirectorySortDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
79- OnPropertyChanged ( ) ;
80- }
81- }
82- }
86+ OnPropertyChanged ( nameof ( SelectedDefaultSortingIndex ) ) ;
8387
84- public bool GroupInDescendingOrder
85- {
86- get => UserSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection == SortDirection . Descending ;
87- set
88- {
89- if ( value != ( UserSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection == SortDirection . Descending ) )
90- {
91- UserSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
92- OnPropertyChanged ( ) ;
88+ UserSettingsService . LayoutSettingsService . DefaultSortOption = value == FileTagSortingIndex ? SortOption . FileTag : ( SortOption ) value ;
9389 }
9490 }
9591 }
9692
97- public bool IsDefaultGrouped
98- => UserSettingsService . LayoutSettingsService . DefaultGroupOption != GroupOption . None ;
99-
100- private int defaultGroupByDateUnitIndex ;
101- public int SelectedDefaultGroupByDateUnitIndex
93+ public bool SortInDescendingOrder
10294 {
103- get => defaultGroupByDateUnitIndex ;
95+ get => UserSettingsService . LayoutSettingsService . DefaultDirectorySortDirection == SortDirection . Descending ;
10496 set
10597 {
106- if ( SetProperty ( ref defaultGroupByDateUnitIndex , value ) )
98+ if ( value != ( UserSettingsService . LayoutSettingsService . DefaultDirectorySortDirection == SortDirection . Descending ) )
10799 {
108- OnPropertyChanged ( nameof ( SelectedDefaultGroupByDateUnitIndex ) ) ;
109- UserSettingsService . LayoutSettingsService . DefaultGroupByDateUnit = ( GroupByDateUnit ) value ;
100+ UserSettingsService . LayoutSettingsService . DefaultDirectorySortDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
101+ OnPropertyChanged ( ) ;
110102 }
111103 }
112104 }
113105
114- public bool IsGroupByDate
115- => UserSettingsService . LayoutSettingsService . DefaultGroupOption . IsGroupByDate ( ) ;
116-
106+
117107 private int selectedDefaultSortPriorityIndex ;
118108 public int SelectedDefaultSortPriorityIndex
119109 {
@@ -144,20 +134,8 @@ public int SelectedDefaultSortPriorityIndex
144134 }
145135 }
146136
147- private int selectedDefaultSortingIndex ;
148- public int SelectedDefaultSortingIndex
149- {
150- get => selectedDefaultSortingIndex ;
151- set
152- {
153- if ( SetProperty ( ref selectedDefaultSortingIndex , value ) )
154- {
155- OnPropertyChanged ( nameof ( SelectedDefaultSortingIndex ) ) ;
156137
157- UserSettingsService . LayoutSettingsService . DefaultSortOption = value == FileTagSortingIndex ? SortOption . FileTag : ( SortOption ) value ;
158- }
159- }
160- }
138+ // Grouping options
161139
162140 private int selectedDefaultGroupingIndex ;
163141 public int SelectedDefaultGroupingIndex
@@ -178,6 +156,43 @@ public int SelectedDefaultGroupingIndex
178156 }
179157 }
180158
159+ public bool GroupInDescendingOrder
160+ {
161+ get => UserSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection == SortDirection . Descending ;
162+ set
163+ {
164+ if ( value != ( UserSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection == SortDirection . Descending ) )
165+ {
166+ UserSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection = value ? SortDirection . Descending : SortDirection . Ascending ;
167+ OnPropertyChanged ( ) ;
168+ }
169+ }
170+ }
171+
172+ private int defaultGroupByDateUnitIndex ;
173+
174+ public int SelectedDefaultGroupByDateUnitIndex
175+ {
176+ get => defaultGroupByDateUnitIndex ;
177+ set
178+ {
179+ if ( SetProperty ( ref defaultGroupByDateUnitIndex , value ) )
180+ {
181+ OnPropertyChanged ( nameof ( SelectedDefaultGroupByDateUnitIndex ) ) ;
182+ UserSettingsService . LayoutSettingsService . DefaultGroupByDateUnit = ( GroupByDateUnit ) value ;
183+ }
184+ }
185+ }
186+
187+ public bool IsGroupByDate
188+ => UserSettingsService . LayoutSettingsService . DefaultGroupOption . IsGroupByDate ( ) ;
189+
190+ public bool IsDefaultGrouped
191+ => UserSettingsService . LayoutSettingsService . DefaultGroupOption != GroupOption . None ;
192+
193+
194+ // Details view
195+
181196 public bool ShowFileTagColumn
182197 {
183198 get => UserSettingsService . LayoutSettingsService . ShowFileTagColumn ;
@@ -248,6 +263,9 @@ public bool ShowDateColumn
248263 }
249264 }
250265
266+
267+ // Methods
268+
251269 public void ResetLayoutPreferences ( )
252270 {
253271 // Is this proper practice?
0 commit comments