-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code Quality: Replace 'Format Drive' commands with actions (#16468)
- Loading branch information
Showing
11 changed files
with
104 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Files.App/Actions/FileSystem/FormatDriveFromHomeAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class FormatDriveFromHomeAction : FormatDriveAction | ||
{ | ||
private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>(); | ||
|
||
private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>(); | ||
|
||
public override bool IsExecutable => | ||
HomePageContext.IsAnyItemRightClicked && | ||
HomePageContext.RightClickedItem is not null && | ||
HomePageContext.RightClickedItem.Path is not null && | ||
drivesViewModel.Drives | ||
.Cast<DriveItem>() | ||
.FirstOrDefault(x => string.Equals(x.Path, HomePageContext.RightClickedItem.Path)) is DriveItem driveItem && | ||
!(driveItem.Type == DriveType.Network || string.Equals(HomePageContext.RightClickedItem.Path, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase)); | ||
|
||
public override bool IsAccessibleGlobally | ||
=> false; | ||
|
||
public override Task ExecuteAsync(object? parameter = null) | ||
{ | ||
return Win32Helper.OpenFormatDriveDialog(HomePageContext?.RightClickedItem?.Path ?? string.Empty); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Files.App/Actions/FileSystem/FormatDriveFromSidebarAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class FormatDriveFromSidebarAction : FormatDriveAction | ||
{ | ||
private ISidebarContext SidebarContext { get; } = Ioc.Default.GetRequiredService<ISidebarContext>(); | ||
|
||
private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>(); | ||
|
||
public override bool IsExecutable => | ||
SidebarContext.IsItemRightClicked && | ||
SidebarContext.RightClickedItem is not null && | ||
SidebarContext.RightClickedItem.Path is not null && | ||
drivesViewModel.Drives | ||
.Cast<DriveItem>() | ||
.FirstOrDefault(x => string.Equals(x.Path, SidebarContext.RightClickedItem.Path)) is DriveItem driveItem && | ||
!(driveItem.Type == DriveType.Network || string.Equals(SidebarContext.RightClickedItem.Path, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase)); | ||
|
||
public override bool IsAccessibleGlobally | ||
=> false; | ||
|
||
public override Task ExecuteAsync(object? parameter = null) | ||
{ | ||
return Win32Helper.OpenFormatDriveDialog(SidebarContext?.RightClickedItem?.Path ?? string.Empty); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.