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: Added support for formatting drives from the properties window #13173

Merged
merged 6 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/Files.App/Helpers/MenuFlyout/ShellContextMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ public static async Task LoadShellMenuItems(
(showSendToMenu || !UserSettingsService.GeneralSettingsService.ShowSendToMenu))
shellMenuItems.Remove(sendToItem);

var turnOnBitLocker = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "encrypt-bde-elev" });
var turnOnBitLocker = shellMenuItems.FirstOrDefault(x =>
x.Tag is Win32ContextMenuItem menuItem &&
menuItem.CommandString.StartsWith("encrypt-bde"));

if (turnOnBitLocker is not null)
shellMenuItems.Remove(turnOnBitLocker);

Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3438,4 +3438,7 @@
<data name="CopyFailureFileToLarge" xml:space="preserve">
<value>The following items are too large to be copied to this drive</value>
</data>
<data name="FormatYourDrive" xml:space="preserve">
<value>Format your drive</value>
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
</data>
</root>
2 changes: 1 addition & 1 deletion src/Files.App/Views/LayoutModes/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> s
{
var openWithMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "openas" });
var sendToMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "sendto" });
var turnOnBitLockerMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "encrypt-bde-elev" });
var turnOnBitLockerMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem menuItem && menuItem.CommandString.StartsWith("encrypt-bde"));
var manageBitLockerMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "manage-bde" });
var shellMenuItemsFiltered = shellMenuItems.Where(x => x != openWithMenuItem && x != sendToMenuItem && x != turnOnBitLockerMenuItem && x != manageBitLockerMenuItem).ToList();
var mainShellMenuItems = shellMenuItemsFiltered.RemoveFrom(!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu ? int.MaxValue : shiftPressed ? 6 : 0);
Expand Down
18 changes: 18 additions & 0 deletions src/Files.App/Views/Properties/GeneralPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<!-- Space Used Progress -->
Expand Down Expand Up @@ -564,6 +565,23 @@
Click="DiskCleanupButton_Click"
Content="{helpers:ResourceString Name=DiskCleanup}" />
yaira2 marked this conversation as resolved.
Show resolved Hide resolved

<!-- Format Disk -->
<TextBlock
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
Grid.Row="5"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="4,0,0,0"
Style="{StaticResource PropertyValueTextBlock}"
Text="{helpers:ResourceString Name=FormatYourDrive}" />

<Button
x:Name="FormatDiskButton"
Grid.Row="5"
Grid.Column="2"
Grid.ColumnSpan="2"
HorizontalAlignment="Right"
Click="FormatDiskButton_Click"
Content="{helpers:ResourceString Name=FormatDriveText}" />
</Grid>

<!-- Item Attributes -->
Expand Down
10 changes: 8 additions & 2 deletions src/Files.App/Views/Properties/GeneralPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ private void ItemFileName_LosingFocus(UIElement _, LosingFocusEventArgs e)
ItemFileName.Text += match.Value;
}

private void DiskCleanupButton_Click(object _, RoutedEventArgs e)
private async void DiskCleanupButton_Click(object _, RoutedEventArgs e)
{
if (BaseProperties is DriveProperties driveProps)
StorageSenseHelper.OpenStorageSense(driveProps.Drive.Path);
await StorageSenseHelper.OpenStorageSense(driveProps.Drive.Path);
}

private async void FormatDiskButton_Click(object sender, RoutedEventArgs e)
{
if (BaseProperties is DriveProperties driveProps)
await Win32API.OpenFormatDriveDialog(driveProps.Drive.Path);
}

private void UpdateDateDisplayTimer_Tick(object sender, object e)
Expand Down