@@ -20,7 +20,7 @@ public override RichGlyph Glyph
20
20
public override HotKey HotKey
21
21
=> new ( Keys . Number1 , KeyModifiers . CtrlShift ) ;
22
22
}
23
-
23
+
24
24
internal class LayoutListAction : ToggleLayoutAction
25
25
{
26
26
protected override LayoutTypes LayoutType
@@ -57,60 +57,24 @@ public override HotKey HotKey
57
57
=> new ( Keys . Number3 , KeyModifiers . CtrlShift ) ;
58
58
}
59
59
60
- internal class LayoutGridSmallAction : ToggleLayoutAction
60
+ internal class LayoutGridAction : ToggleLayoutAction
61
61
{
62
62
protected override LayoutTypes LayoutType
63
- => LayoutTypes . GridSmall ;
63
+ => LayoutTypes . Grid ;
64
64
65
65
public override string Label
66
- => "SmallIcons " . GetLocalizedResource ( ) ;
66
+ => "Grid " . GetLocalizedResource ( ) ;
67
67
68
68
public override string Description
69
- => "LayoutGridSmallDescription " . GetLocalizedResource ( ) ;
69
+ => "LayoutGridescription " . GetLocalizedResource ( ) ;
70
70
71
71
public override RichGlyph Glyph
72
- => new ( opacityStyle : "ColorIconGridSmallLayout " ) ;
72
+ => new ( opacityStyle : "ColorIconGridLayout " ) ;
73
73
74
74
public override HotKey HotKey
75
75
=> new ( Keys . Number4 , KeyModifiers . CtrlShift ) ;
76
76
}
77
77
78
- internal class LayoutGridMediumAction : ToggleLayoutAction
79
- {
80
- protected override LayoutTypes LayoutType
81
- => LayoutTypes . GridMedium ;
82
-
83
- public override string Label
84
- => "MediumIcons" . GetLocalizedResource ( ) ;
85
-
86
- public override string Description
87
- => "LayoutGridMediumDescription" . GetLocalizedResource ( ) ;
88
-
89
- public override RichGlyph Glyph
90
- => new ( opacityStyle : "ColorIconGridMediumLayout" ) ;
91
-
92
- public override HotKey HotKey
93
- => new ( Keys . Number5 , KeyModifiers . CtrlShift ) ;
94
- }
95
-
96
- internal class LayoutGridLargeAction : ToggleLayoutAction
97
- {
98
- protected override LayoutTypes LayoutType
99
- => LayoutTypes . GridLarge ;
100
-
101
- public override string Label
102
- => "LargeIcons" . GetLocalizedResource ( ) ;
103
-
104
- public override string Description
105
- => "LayoutGridLargeDescription" . GetLocalizedResource ( ) ;
106
-
107
- public override RichGlyph Glyph
108
- => new ( opacityStyle : "ColorIconGridLargeLayout" ) ;
109
-
110
- public override HotKey HotKey
111
- => new ( Keys . Number6 , KeyModifiers . CtrlShift ) ;
112
- }
113
-
114
78
internal class LayoutColumnsAction : ToggleLayoutAction
115
79
{
116
80
protected override LayoutTypes LayoutType
@@ -126,7 +90,7 @@ public override RichGlyph Glyph
126
90
=> new ( opacityStyle : "ColorIconColumnsLayout" ) ;
127
91
128
92
public override HotKey HotKey
129
- => new ( Keys . Number7 , KeyModifiers . CtrlShift ) ;
93
+ => new ( Keys . Number5 , KeyModifiers . CtrlShift ) ;
130
94
}
131
95
132
96
internal class LayoutAdaptiveAction : ToggleLayoutAction
@@ -204,9 +168,11 @@ protected virtual void OnContextChanged(string propertyName)
204
168
}
205
169
}
206
170
207
- internal class LayoutDecreaseSizeAction : IAction
171
+ internal class LayoutDecreaseSizeAction : ObservableObject , IAction
208
172
{
209
- private readonly IDisplayPageContext context ;
173
+ private static readonly IUserSettingsService UserSettingsService = Ioc . Default . GetRequiredService < IUserSettingsService > ( ) ;
174
+ private readonly IDisplayPageContext DisplayPageContext = Ioc . Default . GetRequiredService < IDisplayPageContext > ( ) ;
175
+ private readonly IContentPageContext ContentPageContext = Ioc . Default . GetRequiredService < IContentPageContext > ( ) ;
210
176
211
177
public string Label
212
178
=> "DecreaseSize" . GetLocalizedResource ( ) ;
@@ -220,22 +186,86 @@ public HotKey HotKey
220
186
public HotKey MediaHotKey
221
187
=> new ( Keys . OemMinus , KeyModifiers . Ctrl , false ) ;
222
188
189
+ public bool IsExecutable =>
190
+ ContentPageContext . PageType is not ContentPageTypes . Home &&
191
+ ( ( DisplayPageContext . LayoutType == LayoutTypes . Details && UserSettingsService . LayoutSettingsService . ItemSizeDetailsView > Constants . IconHeights . DetailsView . Minimum ) ||
192
+ ( DisplayPageContext . LayoutType == LayoutTypes . List && UserSettingsService . LayoutSettingsService . ItemSizeListView > Constants . IconHeights . ListView . Minimum ) ||
193
+ ( DisplayPageContext . LayoutType == LayoutTypes . Grid && UserSettingsService . LayoutSettingsService . ItemSizeGridView > Constants . IconHeights . GridView . Minimum ) ||
194
+ ( DisplayPageContext . LayoutType == LayoutTypes . Columns && UserSettingsService . LayoutSettingsService . ItemSizeColumnsView > Constants . IconHeights . ColumnsView . Minimum ) ) ;
195
+
223
196
public LayoutDecreaseSizeAction ( )
224
197
{
225
- context = Ioc . Default . GetRequiredService < IDisplayPageContext > ( ) ;
198
+ ContentPageContext . PropertyChanged += ContentPageContext_PropertyChanged ;
199
+ DisplayPageContext . PropertyChanged += DisplayPageContext_PropertyChanged ;
200
+ UserSettingsService . LayoutSettingsService . PropertyChanged += UserSettingsService_PropertyChanged ;
201
+ }
202
+
203
+ private void ContentPageContext_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
204
+ {
205
+ switch ( e . PropertyName )
206
+ {
207
+ case nameof ( IContentPageContext . PageType ) :
208
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
209
+ break ;
210
+ }
211
+ }
212
+
213
+ private void DisplayPageContext_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
214
+ {
215
+ switch ( e . PropertyName )
216
+ {
217
+ case nameof ( IDisplayPageContext . LayoutType ) :
218
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
219
+ break ;
220
+ }
221
+ }
222
+
223
+ private void UserSettingsService_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
224
+ {
225
+ switch ( e . PropertyName )
226
+ {
227
+ case nameof ( ILayoutSettingsService . ItemSizeDetailsView ) :
228
+ case nameof ( ILayoutSettingsService . ItemSizeListView ) :
229
+ case nameof ( ILayoutSettingsService . ItemSizeGridView ) :
230
+ case nameof ( ILayoutSettingsService . ItemSizeColumnsView ) :
231
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
232
+ break ;
233
+ }
226
234
}
227
235
228
236
public Task ExecuteAsync ( )
229
237
{
230
- context . DecreaseLayoutSize ( ) ;
238
+ switch ( DisplayPageContext . LayoutType )
239
+ {
240
+ case LayoutTypes . Details :
241
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeDetailsView > Constants . IconHeights . DetailsView . Minimum )
242
+ UserSettingsService . LayoutSettingsService . ItemSizeDetailsView -= Constants . IconHeights . DetailsView . Increment ;
243
+ break ;
244
+ case LayoutTypes . List :
245
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeListView > Constants . IconHeights . ListView . Minimum )
246
+ UserSettingsService . LayoutSettingsService . ItemSizeListView -= Constants . IconHeights . ListView . Increment ;
247
+ break ;
248
+ case LayoutTypes . Tiles :
249
+ break ;
250
+ case LayoutTypes . Grid :
251
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeGridView > Constants . IconHeights . GridView . Minimum )
252
+ UserSettingsService . LayoutSettingsService . ItemSizeGridView -= Constants . IconHeights . GridView . Increment ;
253
+ break ;
254
+ case LayoutTypes . Columns :
255
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeColumnsView > Constants . IconHeights . ColumnsView . Minimum )
256
+ UserSettingsService . LayoutSettingsService . ItemSizeColumnsView -= Constants . IconHeights . ColumnsView . Increment ;
257
+ break ;
258
+ }
231
259
232
260
return Task . CompletedTask ;
233
261
}
234
262
}
235
263
236
- internal class LayoutIncreaseSizeAction : IAction
264
+ internal class LayoutIncreaseSizeAction : ObservableObject , IAction
237
265
{
238
- private readonly IDisplayPageContext context ;
266
+ private static readonly IUserSettingsService UserSettingsService = Ioc . Default . GetRequiredService < IUserSettingsService > ( ) ;
267
+ private readonly IDisplayPageContext DisplayPageContext = Ioc . Default . GetRequiredService < IDisplayPageContext > ( ) ;
268
+ private readonly IContentPageContext ContentPageContext = Ioc . Default . GetRequiredService < IContentPageContext > ( ) ;
239
269
240
270
public string Label
241
271
=> "IncreaseSize" . GetLocalizedResource ( ) ;
@@ -249,14 +279,76 @@ public HotKey HotKey
249
279
public HotKey MediaHotKey
250
280
=> new ( Keys . OemPlus , KeyModifiers . Ctrl , false ) ;
251
281
282
+ public bool IsExecutable =>
283
+ ContentPageContext . PageType is not ContentPageTypes . Home &&
284
+ ( ( DisplayPageContext . LayoutType == LayoutTypes . Details && UserSettingsService . LayoutSettingsService . ItemSizeDetailsView < Constants . IconHeights . DetailsView . Maximum ) ||
285
+ ( DisplayPageContext . LayoutType == LayoutTypes . List && UserSettingsService . LayoutSettingsService . ItemSizeListView < Constants . IconHeights . ListView . Maximum ) ||
286
+ ( DisplayPageContext . LayoutType == LayoutTypes . Grid && UserSettingsService . LayoutSettingsService . ItemSizeGridView < Constants . IconHeights . GridView . Maximum ) ||
287
+ ( DisplayPageContext . LayoutType == LayoutTypes . Columns && UserSettingsService . LayoutSettingsService . ItemSizeColumnsView < Constants . IconHeights . ColumnsView . Maximum ) ) ;
288
+
252
289
public LayoutIncreaseSizeAction ( )
253
290
{
254
- context = Ioc . Default . GetRequiredService < IDisplayPageContext > ( ) ;
291
+ ContentPageContext . PropertyChanged += ContentPageContext_PropertyChanged ;
292
+ DisplayPageContext . PropertyChanged += DisplayPageContext_PropertyChanged ;
293
+ UserSettingsService . LayoutSettingsService . PropertyChanged += UserSettingsService_PropertyChanged ;
294
+ }
295
+
296
+ private void ContentPageContext_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
297
+ {
298
+ switch ( e . PropertyName )
299
+ {
300
+ case nameof ( IContentPageContext . PageType ) :
301
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
302
+ break ;
303
+ }
304
+ }
305
+
306
+ private void DisplayPageContext_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
307
+ {
308
+ switch ( e . PropertyName )
309
+ {
310
+ case nameof ( IDisplayPageContext . LayoutType ) :
311
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
312
+ break ;
313
+ }
314
+ }
315
+
316
+ private void UserSettingsService_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
317
+ {
318
+ switch ( e . PropertyName )
319
+ {
320
+ case nameof ( ILayoutSettingsService . ItemSizeDetailsView ) :
321
+ case nameof ( ILayoutSettingsService . ItemSizeListView ) :
322
+ case nameof ( ILayoutSettingsService . ItemSizeGridView ) :
323
+ case nameof ( ILayoutSettingsService . ItemSizeColumnsView ) :
324
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
325
+ break ;
326
+ }
255
327
}
256
328
257
329
public Task ExecuteAsync ( )
258
330
{
259
- context . IncreaseLayoutSize ( ) ;
331
+ switch ( DisplayPageContext . LayoutType )
332
+ {
333
+ case LayoutTypes . Details :
334
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeDetailsView < Constants . IconHeights . DetailsView . Maximum )
335
+ UserSettingsService . LayoutSettingsService . ItemSizeDetailsView += Constants . IconHeights . DetailsView . Increment ;
336
+ break ;
337
+ case LayoutTypes . List :
338
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeListView < Constants . IconHeights . ListView . Maximum )
339
+ UserSettingsService . LayoutSettingsService . ItemSizeListView += Constants . IconHeights . ListView . Increment ;
340
+ break ;
341
+ case LayoutTypes . Tiles :
342
+ break ;
343
+ case LayoutTypes . Grid :
344
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeGridView < Constants . IconHeights . GridView . Maximum )
345
+ UserSettingsService . LayoutSettingsService . ItemSizeGridView += Constants . IconHeights . GridView . Increment ;
346
+ break ;
347
+ case LayoutTypes . Columns :
348
+ if ( UserSettingsService . LayoutSettingsService . ItemSizeColumnsView < Constants . IconHeights . ColumnsView . Maximum )
349
+ UserSettingsService . LayoutSettingsService . ItemSizeColumnsView += Constants . IconHeights . ColumnsView . Increment ;
350
+ break ;
351
+ }
260
352
261
353
return Task . CompletedTask ;
262
354
}
0 commit comments