Skip to content

Commit 7da8156

Browse files
authored
Open drive selection page when opening StorageSense for drive != C: (#6668)
1 parent d35cb26 commit 7da8156

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Files.Launcher/MessageHandlers/ApplicationLaunchHandler.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ public Task ParseArgumentsAsync(PipeStream connection, Dictionary<string, object
2424
{
2525
switch (arguments)
2626
{
27+
case "LaunchSettings":
28+
{
29+
var page = message.Get("page", (string)null);
30+
var appActiveManager = new Shell32.IApplicationActivationManager();
31+
appActiveManager.ActivateApplication("windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel",
32+
page, Shell32.ACTIVATEOPTIONS.AO_NONE, out _);
33+
break;
34+
}
35+
2736
case "LaunchApp":
2837
if (message.ContainsKey("Application"))
2938
{

Files/UserControls/Widgets/DrivesWidget.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
Background="Transparent"
227227
BorderBrush="Transparent"
228228
Click="GoToStorageSense_Click"
229+
Tag="{x:Bind Path}"
229230
ToolTipService.ToolTip="Open Storage Sense">
230231
<FontIcon
231232
HorizontalAlignment="Center"

Files/UserControls/Widgets/DrivesWidget.xaml.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Runtime.CompilerServices;
1414
using System.Threading.Tasks;
1515
using Windows.Foundation.Collections;
16+
using Windows.Foundation.Metadata;
1617
using Windows.System;
1718
using Windows.UI.Core;
1819
using Windows.UI.Xaml;
@@ -198,7 +199,22 @@ await connection.SendMessageAsync(new ValueSet()
198199

199200
private async void GoToStorageSense_Click(object sender, RoutedEventArgs e)
200201
{
201-
await Launcher.LaunchUriAsync(new Uri("ms-settings:storagesense"));
202+
string clickedCard = (sender as Button).Tag.ToString();
203+
var connection = await AppServiceConnectionHelper.Instance;
204+
if (connection != null
205+
&& !clickedCard.StartsWith("C:", StringComparison.OrdinalIgnoreCase)
206+
&& ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
207+
{
208+
await connection.SendMessageAsync(new ValueSet()
209+
{
210+
{ "Arguments", "LaunchSettings" },
211+
{ "page", "page=SettingsPageStorageSenseStorageOverview&target=SystemSettings_StorageSense_VolumeListLink" }
212+
});
213+
}
214+
else
215+
{
216+
await Launcher.LaunchUriAsync(new Uri("ms-settings:storagesense"));
217+
}
202218
}
203219

204220
private async Task<bool> CheckEmptyDrive(string drivePath)

0 commit comments

Comments
 (0)