Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: New enum Keys and KeyModifiers #11891

Merged
merged 8 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Files.App/Actions/Content/Archives/DecompressArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Files.App.Helpers;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -18,7 +17,7 @@ internal class DecompressArchive : ObservableObject, IAction

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

public HotKey HotKey { get; } = new(VirtualKey.E, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.E, KeyModifiers.Ctrl);

public bool IsExecutable => IsContextPageTypeAdaptedToCommand()
&& ArchiveHelpers.CanDecompress(context.SelectedItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
using Files.App.Extensions;
using Files.App.Helpers;
using System.Threading.Tasks;
using Windows.System;

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

public HotKey HotKey { get; } = new(VirtualKey.Space);
public HotKey HotKey { get; } = new(Keys.Space);

public bool IsExecutable => context.SelectedItems.Count == 1 &&
(!context.ShellPage?.ToolbarViewModel?.IsEditModeEnabled ?? false) &&
Expand Down
6 changes: 2 additions & 4 deletions src/Files.App/Actions/Content/RefreshItemsAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Files.App.Extensions;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

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

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

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

public HotKey SecondHotKey { get; } = new(VirtualKey.F5);

public bool IsExecutable => context.CanRefresh;

public RefreshItemsAction()
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Actions/Content/Selection/SelectAllAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Files.App.Contexts;
using Files.App.Extensions;
using System.Threading.Tasks;
using Windows.System;

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

public RichGlyph Glyph { get; } = new("\uE8B3");
public HotKey HotKey { get; } = new(VirtualKey.A, VirtualKeyModifiers.Control);

public HotKey HotKey { get; } = new(Keys.A, KeyModifiers.Ctrl);

public bool IsExecutable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using System.Threading.Tasks;
using Windows.System;

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

public HotKey HotKey { get; } = new(VirtualKey.Space, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.Space, KeyModifiers.Ctrl);

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

Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Actions/Display/GroupAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void DisplayContext_PropertyChanged(object? sender, PropertyChangedEvent

internal class GroupAscendingAction : ObservableObject, IToggleAction
{
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();

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

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

internal class GroupDescendingAction : ObservableObject, IToggleAction
{
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();

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

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

internal class ToggleGroupDirectionAction : IAction
{
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();

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

Expand Down
23 changes: 11 additions & 12 deletions src/Files.App/Actions/Display/LayoutAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Files.App.Extensions;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

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

public override RichGlyph Glyph { get; } = new("\uE179");
public override HotKey HotKey { get; } = new(VirtualKey.Number1, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
public override HotKey HotKey { get; } = new(Keys.Number1, KeyModifiers.CtrlShift);
}

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

public override RichGlyph Glyph { get; } = new("\uE15C");
public override HotKey HotKey { get; } = new(VirtualKey.Number2, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
public override HotKey HotKey { get; } = new(Keys.Number2, KeyModifiers.CtrlShift);
}

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

public override RichGlyph Glyph { get; } = new("\uE80A");
public override HotKey HotKey { get; } = new(VirtualKey.Number3, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
public override HotKey HotKey { get; } = new(Keys.Number3, KeyModifiers.CtrlShift);
}

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

public override RichGlyph Glyph { get; } = new("\uF0E2");
public override HotKey HotKey { get; } = new(VirtualKey.Number4, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
public override HotKey HotKey { get; } = new(Keys.Number4, KeyModifiers.CtrlShift);
}

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

public override RichGlyph Glyph { get; } = new("\uE739");
public override HotKey HotKey { get; } = new(VirtualKey.Number5, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
public override HotKey HotKey { get; } = new(Keys.Number5, KeyModifiers.CtrlShift);
}

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

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

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

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

protected override void OnContextChanged(string propertyName)
{
Expand Down Expand Up @@ -137,8 +136,8 @@ internal class LayoutDecreaseSizeAction : IAction

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

public HotKey HotKey { get; } = new(VirtualKey.Subtract, VirtualKeyModifiers.Control);
public HotKey MediaHotKey { get; } = new((VirtualKey)189, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.Subtract, KeyModifiers.Ctrl);
public HotKey MediaHotKey { get; } = new(Keys.OemMinus, KeyModifiers.Ctrl);

public Task ExecuteAsync()
{
Expand All @@ -155,8 +154,8 @@ internal class LayoutIncreaseSizeAction : IAction

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

public HotKey HotKey { get; } = new(VirtualKey.Add, VirtualKeyModifiers.Control);
public HotKey MediaHotKey { get; } = new((VirtualKey)187, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.Add, KeyModifiers.Ctrl);
public HotKey MediaHotKey { get; } = new(Keys.OemPlus, KeyModifiers.Ctrl);

public Task ExecuteAsync()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Actions/Display/SortAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ internal class SortByDateDeletedAction : SortByAction

internal abstract class SortByAction : ObservableObject, IToggleAction
{
private IContentPageContext contentContext = Ioc.Default.GetRequiredService<IContentPageContext>();
private IDisplayPageContext displayContext = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IContentPageContext contentContext = Ioc.Default.GetRequiredService<IContentPageContext>();
private readonly IDisplayPageContext displayContext = Ioc.Default.GetRequiredService<IDisplayPageContext>();

protected abstract SortOption SortOption { get; }

Expand Down Expand Up @@ -126,7 +126,7 @@ private void DisplayContext_PropertyChanged(object? sender, PropertyChangedEvent

internal class SortAscendingAction : ObservableObject, IToggleAction
{
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();

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

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

internal class SortDescendingAction : ObservableObject, IToggleAction
{
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();

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

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

internal class ToggleSortDirectionAction : IAction
{
private IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
private readonly IDisplayPageContext context = Ioc.Default.GetRequiredService<IDisplayPageContext>();

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

Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Actions/FileSystem/CopyItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Files.App.Helpers;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -20,7 +19,7 @@ internal class CopyItemAction : ObservableObject, IAction

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

public HotKey HotKey { get; } = new(VirtualKey.C, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.C, KeyModifiers.Ctrl);

public bool IsExecutable => context.HasSelection;

Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Actions/FileSystem/CopyPathAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -20,7 +19,7 @@ internal class CopyPathAction : IAction

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

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

public async Task ExecuteAsync()
{
Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Actions/FileSystem/CutItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Files.App.Helpers;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -20,7 +19,7 @@ internal class CutItemAction : ObservableObject, IAction

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

public HotKey HotKey { get; } = new(VirtualKey.X, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.X, KeyModifiers.Ctrl);

public bool IsExecutable => context.HasSelection;

Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Actions/FileSystem/DeleteItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -25,7 +24,7 @@ internal class DeleteItemAction : ObservableObject, IAction

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

public HotKey HotKey { get; } = new(VirtualKey.Delete);
public HotKey HotKey { get; } = new(Keys.Delete);

public bool IsExecutable =>
context.HasSelection &&
Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Actions/FileSystem/OpenItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -24,7 +23,7 @@ internal class OpenItemAction : ObservableObject, IAction

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

public HotKey HotKey => new(VirtualKey.Enter);
public HotKey HotKey => new(Keys.Enter);

private const int MaxOpenCount = 10;

Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Actions/FileSystem/PasteItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Files.App.Helpers;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -21,7 +20,7 @@ internal class PasteItemAction : ObservableObject, IAction

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

public HotKey HotKey { get; } = new(VirtualKey.V, VirtualKeyModifiers.Control);
public HotKey HotKey { get; } = new(Keys.V, KeyModifiers.Ctrl);

private bool isExecutable;
public bool IsExecutable => isExecutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Files.App.Helpers;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;

namespace Files.App.Actions
{
Expand All @@ -22,7 +21,7 @@ internal class PasteItemToSelectionAction : ObservableObject, IAction

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

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

private bool isExecutable;
public bool IsExecutable => isExecutable;
Expand Down
11 changes: 5 additions & 6 deletions src/Files.App/Actions/FileSystem/RenameAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Files.App.Contexts;
using Files.App.Extensions;
using System.Threading.Tasks;
using Windows.System;

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

public string Label { get; } = "Rename".GetLocalizedResource();

public string Description { get; } = "TODO";

public HotKey HotKey { get; } = new(VirtualKey.F2);
public HotKey HotKey { get; } = new(Keys.F2);

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

public bool IsExecutable =>
context.ShellPage is not null &&
public bool IsExecutable =>
context.ShellPage is not null &&
IsPageTypeValid() &&
context.ShellPage.SlimContentPage is not null &&
context.ShellPage.SlimContentPage is not null &&
IsSelectionValid();

public RenameAction()
Expand Down
Loading