Skip to content

Commit bc9f537

Browse files
authored
Feature: New enum Keys and KeyModifiers (#11891)
1 parent 5d67015 commit bc9f537

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+555
-446
lines changed

src/Files.App/Actions/Content/Archives/DecompressArchive.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Files.App.Helpers;
77
using System.ComponentModel;
88
using System.Threading.Tasks;
9-
using Windows.System;
109

1110
namespace Files.App.Actions
1211
{
@@ -18,7 +17,7 @@ internal class DecompressArchive : ObservableObject, IAction
1817

1918
public string Description => "TODO: Need to be described.";
2019

21-
public HotKey HotKey { get; } = new(VirtualKey.E, VirtualKeyModifiers.Control);
20+
public HotKey HotKey { get; } = new(Keys.E, KeyModifiers.Ctrl);
2221

2322
public bool IsExecutable => IsContextPageTypeAdaptedToCommand()
2423
&& ArchiveHelpers.CanDecompress(context.SelectedItems);

src/Files.App/Actions/Content/QuickLook/LaunchQuickLookAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
using Files.App.Extensions;
66
using Files.App.Helpers;
77
using System.Threading.Tasks;
8-
using Windows.System;
98

109
namespace Files.App.Actions
1110
{
1211
internal class LaunchQuickLookAction : ObservableObject, IAction
1312
{
1413
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
1514

16-
public HotKey HotKey { get; } = new(VirtualKey.Space);
15+
public HotKey HotKey { get; } = new(Keys.Space);
1716

1817
public bool IsExecutable => context.SelectedItems.Count == 1 &&
1918
(!context.ShellPage?.ToolbarViewModel?.IsEditModeEnabled ?? false) &&

src/Files.App/Actions/Content/RefreshItemsAction.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Files.App.Extensions;
66
using System.ComponentModel;
77
using System.Threading.Tasks;
8-
using Windows.System;
98

109
namespace Files.App.Actions
1110
{
@@ -18,10 +17,9 @@ internal class RefreshItemsAction : ObservableObject, IAction
1817

1918
public RichGlyph Glyph { get; } = new("\uE72C");
2019

21-
public HotKey HotKey { get; } = new(VirtualKey.R, VirtualKeyModifiers.Control);
20+
public HotKey HotKey { get; } = new(Keys.R, KeyModifiers.Ctrl);
21+
public HotKey SecondHotKey { get; } = new(Keys.F5);
2222

23-
public HotKey SecondHotKey { get; } = new(VirtualKey.F5);
24-
2523
public bool IsExecutable => context.CanRefresh;
2624

2725
public RefreshItemsAction()

src/Files.App/Actions/Content/Selection/SelectAllAction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Files.App.Contexts;
44
using Files.App.Extensions;
55
using System.Threading.Tasks;
6-
using Windows.System;
76

87
namespace Files.App.Actions
98
{
@@ -16,7 +15,8 @@ internal class SelectAllAction : IAction
1615
public string Description => "TODO: Need to be described.";
1716

1817
public RichGlyph Glyph { get; } = new("\uE8B3");
19-
public HotKey HotKey { get; } = new(VirtualKey.A, VirtualKeyModifiers.Control);
18+
19+
public HotKey HotKey { get; } = new(Keys.A, KeyModifiers.Ctrl);
2020

2121
public bool IsExecutable
2222
{

src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Microsoft.UI.Xaml.Controls.Primitives;
44
using Microsoft.UI.Xaml.Input;
55
using System.Threading.Tasks;
6-
using Windows.System;
76

87
namespace Files.App.Actions
98
{
@@ -12,7 +11,7 @@ internal class ToggleSelectAction : IAction
1211
public string Label { get; } = "ToggleSelect".GetLocalizedResource();
1312
public string Description => "TODO: Need to be described.";
1413

15-
public HotKey HotKey { get; } = new(VirtualKey.Space, VirtualKeyModifiers.Control);
14+
public HotKey HotKey { get; } = new(Keys.Space, KeyModifiers.Ctrl);
1615

1716
public bool IsExecutable => GetFocusedElement() is not null;
1817

src/Files.App/Actions/Display/GroupAction.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void DisplayContext_PropertyChanged(object? sender, PropertyChangedEvent
142142

143143
internal class GroupAscendingAction : ObservableObject, IToggleAction
144144
{
145-
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
145+
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
146146

147147
public string Label { get; } = "Ascending".GetLocalizedResource();
148148

@@ -178,7 +178,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
178178

179179
internal class GroupDescendingAction : ObservableObject, IToggleAction
180180
{
181-
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
181+
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
182182

183183
public string Label { get; } = "Descending".GetLocalizedResource();
184184

@@ -214,7 +214,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
214214

215215
internal class ToggleGroupDirectionAction : IAction
216216
{
217-
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
217+
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
218218

219219
public string Label { get; } = "ToggleSortDirection".GetLocalizedResource();
220220

src/Files.App/Actions/Display/LayoutAction.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Files.App.Extensions;
66
using System.ComponentModel;
77
using System.Threading.Tasks;
8-
using Windows.System;
98

109
namespace Files.App.Actions
1110
{
@@ -16,7 +15,7 @@ internal class LayoutDetailsAction : ToggleLayoutAction
1615
public override string Label { get; } = "Details".GetLocalizedResource();
1716

1817
public override RichGlyph Glyph { get; } = new("\uE179");
19-
public override HotKey HotKey { get; } = new(VirtualKey.Number1, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
18+
public override HotKey HotKey { get; } = new(Keys.Number1, KeyModifiers.CtrlShift);
2019
}
2120

2221
internal class LayoutTilesAction : ToggleLayoutAction
@@ -26,7 +25,7 @@ internal class LayoutTilesAction : ToggleLayoutAction
2625
public override string Label { get; } = "Tiles".GetLocalizedResource();
2726

2827
public override RichGlyph Glyph { get; } = new("\uE15C");
29-
public override HotKey HotKey { get; } = new(VirtualKey.Number2, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
28+
public override HotKey HotKey { get; } = new(Keys.Number2, KeyModifiers.CtrlShift);
3029
}
3130

3231
internal class LayoutGridSmallAction : ToggleLayoutAction
@@ -36,7 +35,7 @@ internal class LayoutGridSmallAction : ToggleLayoutAction
3635
public override string Label { get; } = "SmallIcons".GetLocalizedResource();
3736

3837
public override RichGlyph Glyph { get; } = new("\uE80A");
39-
public override HotKey HotKey { get; } = new(VirtualKey.Number3, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
38+
public override HotKey HotKey { get; } = new(Keys.Number3, KeyModifiers.CtrlShift);
4039
}
4140

4241
internal class LayoutGridMediumAction : ToggleLayoutAction
@@ -46,7 +45,7 @@ internal class LayoutGridMediumAction : ToggleLayoutAction
4645
public override string Label { get; } = "MediumIcons".GetLocalizedResource();
4746

4847
public override RichGlyph Glyph { get; } = new("\uF0E2");
49-
public override HotKey HotKey { get; } = new(VirtualKey.Number4, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
48+
public override HotKey HotKey { get; } = new(Keys.Number4, KeyModifiers.CtrlShift);
5049
}
5150

5251
internal class LayoutGridLargeAction : ToggleLayoutAction
@@ -56,7 +55,7 @@ internal class LayoutGridLargeAction : ToggleLayoutAction
5655
public override string Label { get; } = "LargeIcons".GetLocalizedResource();
5756

5857
public override RichGlyph Glyph { get; } = new("\uE739");
59-
public override HotKey HotKey { get; } = new(VirtualKey.Number5, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
58+
public override HotKey HotKey { get; } = new(Keys.Number5, KeyModifiers.CtrlShift);
6059
}
6160

6261
internal class LayoutColumnsAction : ToggleLayoutAction
@@ -66,7 +65,7 @@ internal class LayoutColumnsAction : ToggleLayoutAction
6665
public override string Label { get; } = "Columns".GetLocalizedResource();
6766

6867
public override RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconColumnsLayout");
69-
public override HotKey HotKey { get; } = new(VirtualKey.Number6, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
68+
public override HotKey HotKey { get; } = new(Keys.Number6, KeyModifiers.CtrlShift);
7069
}
7170

7271
internal class LayoutAdaptiveAction : ToggleLayoutAction
@@ -78,7 +77,7 @@ internal class LayoutAdaptiveAction : ToggleLayoutAction
7877
public override bool IsExecutable => Context.IsLayoutAdaptiveEnabled;
7978

8079
public override RichGlyph Glyph { get; } = new("\uF576");
81-
public override HotKey HotKey { get; } = new(VirtualKey.Number7, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
80+
public override HotKey HotKey { get; } = new(Keys.Number7, KeyModifiers.CtrlShift);
8281

8382
protected override void OnContextChanged(string propertyName)
8483
{
@@ -137,8 +136,8 @@ internal class LayoutDecreaseSizeAction : IAction
137136

138137
public string Description => "TODO: Need to be described.";
139138

140-
public HotKey HotKey { get; } = new(VirtualKey.Subtract, VirtualKeyModifiers.Control);
141-
public HotKey MediaHotKey { get; } = new((VirtualKey)189, VirtualKeyModifiers.Control);
139+
public HotKey HotKey { get; } = new(Keys.Subtract, KeyModifiers.Ctrl);
140+
public HotKey MediaHotKey { get; } = new(Keys.OemMinus, KeyModifiers.Ctrl);
142141

143142
public Task ExecuteAsync()
144143
{
@@ -155,8 +154,8 @@ internal class LayoutIncreaseSizeAction : IAction
155154

156155
public string Description => "TODO: Need to be described.";
157156

158-
public HotKey HotKey { get; } = new(VirtualKey.Add, VirtualKeyModifiers.Control);
159-
public HotKey MediaHotKey { get; } = new((VirtualKey)187, VirtualKeyModifiers.Control);
157+
public HotKey HotKey { get; } = new(Keys.Add, KeyModifiers.Ctrl);
158+
public HotKey MediaHotKey { get; } = new(Keys.OemPlus, KeyModifiers.Ctrl);
160159

161160
public Task ExecuteAsync()
162161
{

src/Files.App/Actions/Display/SortAction.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ internal class SortByDateDeletedAction : SortByAction
7979

8080
internal abstract class SortByAction : ObservableObject, IToggleAction
8181
{
82-
private IContentPageContext contentContext = Ioc.Default.GetRequiredService<IContentPageContext>();
83-
private IDisplayPageContext displayContext = Ioc.Default.GetRequiredService<IDisplayPageContext>();
82+
private readonly IContentPageContext contentContext = Ioc.Default.GetRequiredService<IContentPageContext>();
83+
private readonly IDisplayPageContext displayContext = Ioc.Default.GetRequiredService<IDisplayPageContext>();
8484

8585
protected abstract SortOption SortOption { get; }
8686

@@ -126,7 +126,7 @@ private void DisplayContext_PropertyChanged(object? sender, PropertyChangedEvent
126126

127127
internal class SortAscendingAction : ObservableObject, IToggleAction
128128
{
129-
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
129+
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
130130

131131
public string Label { get; } = "Ascending".GetLocalizedResource();
132132

@@ -154,7 +154,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
154154

155155
internal class SortDescendingAction : ObservableObject, IToggleAction
156156
{
157-
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
157+
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
158158

159159
public string Label { get; } = "Descending".GetLocalizedResource();
160160

@@ -182,7 +182,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
182182

183183
internal class ToggleSortDirectionAction : IAction
184184
{
185-
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
185+
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
186186

187187
public string Label { get; } = "ToggleSortDirection".GetLocalizedResource();
188188

src/Files.App/Actions/FileSystem/CopyItemAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Files.App.Helpers;
77
using System.ComponentModel;
88
using System.Threading.Tasks;
9-
using Windows.System;
109

1110
namespace Files.App.Actions
1211
{
@@ -20,7 +19,7 @@ internal class CopyItemAction : ObservableObject, IAction
2019

2120
public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconCopy");
2221

23-
public HotKey HotKey { get; } = new(VirtualKey.C, VirtualKeyModifiers.Control);
22+
public HotKey HotKey { get; } = new(Keys.C, KeyModifiers.Ctrl);
2423

2524
public bool IsExecutable => context.HasSelection;
2625

src/Files.App/Actions/FileSystem/CopyPathAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System;
77
using System.Threading.Tasks;
88
using Windows.ApplicationModel.DataTransfer;
9-
using Windows.System;
109

1110
namespace Files.App.Actions
1211
{
@@ -20,7 +19,7 @@ internal class CopyPathAction : IAction
2019

2120
public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconCopyLocation");
2221

23-
public HotKey HotKey { get; } = new(VirtualKey.C, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
22+
public HotKey HotKey { get; } = new(Keys.C, KeyModifiers.CtrlShift);
2423

2524
public async Task ExecuteAsync()
2625
{

src/Files.App/Actions/FileSystem/CutItemAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Files.App.Helpers;
77
using System.ComponentModel;
88
using System.Threading.Tasks;
9-
using Windows.System;
109

1110
namespace Files.App.Actions
1211
{
@@ -20,7 +19,7 @@ internal class CutItemAction : ObservableObject, IAction
2019

2120
public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconCut");
2221

23-
public HotKey HotKey { get; } = new(VirtualKey.X, VirtualKeyModifiers.Control);
22+
public HotKey HotKey { get; } = new(Keys.X, KeyModifiers.Ctrl);
2423

2524
public bool IsExecutable => context.HasSelection;
2625

src/Files.App/Actions/FileSystem/DeleteItemAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Linq;
1111
using System.Threading.Tasks;
1212
using Windows.Storage;
13-
using Windows.System;
1413

1514
namespace Files.App.Actions
1615
{
@@ -25,7 +24,7 @@ internal class DeleteItemAction : ObservableObject, IAction
2524

2625
public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconDelete");
2726

28-
public HotKey HotKey { get; } = new(VirtualKey.Delete);
27+
public HotKey HotKey { get; } = new(Keys.Delete);
2928

3029
public bool IsExecutable =>
3130
context.HasSelection &&

src/Files.App/Actions/FileSystem/OpenItemAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Linq;
1111
using System.Threading.Tasks;
1212
using Windows.Storage;
13-
using Windows.System;
1413

1514
namespace Files.App.Actions
1615
{
@@ -24,7 +23,7 @@ internal class OpenItemAction : ObservableObject, IAction
2423

2524
public RichGlyph Glyph => new(opacityStyle: "ColorIconOpenFile");
2625

27-
public HotKey HotKey => new(VirtualKey.Enter);
26+
public HotKey HotKey => new(Keys.Enter);
2827

2928
private const int MaxOpenCount = 10;
3029

src/Files.App/Actions/FileSystem/PasteItemAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Files.App.Helpers;
88
using System.ComponentModel;
99
using System.Threading.Tasks;
10-
using Windows.System;
1110

1211
namespace Files.App.Actions
1312
{
@@ -21,7 +20,7 @@ internal class PasteItemAction : ObservableObject, IAction
2120

2221
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconPaste");
2322

24-
public HotKey HotKey { get; } = new(VirtualKey.V, VirtualKeyModifiers.Control);
23+
public HotKey HotKey { get; } = new(Keys.V, KeyModifiers.Ctrl);
2524

2625
private bool isExecutable;
2726
public bool IsExecutable => isExecutable;

src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Files.App.Helpers;
99
using System.ComponentModel;
1010
using System.Threading.Tasks;
11-
using Windows.System;
1211

1312
namespace Files.App.Actions
1413
{
@@ -22,7 +21,7 @@ internal class PasteItemToSelectionAction : ObservableObject, IAction
2221

2322
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconPaste");
2423

25-
public HotKey HotKey { get; } = new(VirtualKey.V, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
24+
public HotKey HotKey { get; } = new(Keys.V, KeyModifiers.CtrlShift);
2625

2726
private bool isExecutable;
2827
public bool IsExecutable => isExecutable;

src/Files.App/Actions/FileSystem/RenameAction.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Files.App.Contexts;
55
using Files.App.Extensions;
66
using System.Threading.Tasks;
7-
using Windows.System;
87

98
namespace Files.App.Actions
109
{
@@ -13,17 +12,17 @@ internal class RenameAction : ObservableObject, IAction
1312
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
1413

1514
public string Label { get; } = "Rename".GetLocalizedResource();
16-
15+
1716
public string Description { get; } = "TODO";
1817

19-
public HotKey HotKey { get; } = new(VirtualKey.F2);
18+
public HotKey HotKey { get; } = new(Keys.F2);
2019

2120
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconRename");
2221

23-
public bool IsExecutable =>
24-
context.ShellPage is not null &&
22+
public bool IsExecutable =>
23+
context.ShellPage is not null &&
2524
IsPageTypeValid() &&
26-
context.ShellPage.SlimContentPage is not null &&
25+
context.ShellPage.SlimContentPage is not null &&
2726
IsSelectionValid();
2827

2928
public RenameAction()

0 commit comments

Comments
 (0)