-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Feature: Added an action to open File Explorers property window #16031
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
Merged
+101
−10
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
269a055
Action
yaira2 93c9145
Fix
yaira2 3e4dc64
Requested changes
yaira2 9e38f67
Update OpenClassicPropertiesAction.cs
yaira2 34979d8
Update OpenClassicPropertiesAction.cs
yaira2 2ae0d75
Update src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs
yaira2 2cd9117
ModifiableCommand
yaira2 5603808
Context menu verb
yaira2 e18e6b2
Revert "Context menu verb"
yaira2 05affbc
Update OpenClassicPropertiesAction.cs
yaira2 71eeb77
Revert "Update OpenClassicPropertiesAction.cs"
yaira2 39b8717
Update OpenClassicPropertiesAction.cs
yaira2 74f1999
Update OpenClassicPropertiesAction.cs
yaira2 6bb1adb
Update src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs
yaira2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -120,4 +120,4 @@ WindowsCreateString | |
WindowsDeleteString | ||
IPreviewHandler | ||
AssocQueryString | ||
GetModuleHandle | ||
ShellExecuteEx |
This file contains hidden or 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,77 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using System.Runtime.InteropServices; | ||
using Windows.Win32; | ||
using Windows.Win32.UI.Shell; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class OpenClassicPropertiesAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context; | ||
|
||
public string Label | ||
=> "OpenClassicProperties".GetLocalizedResource(); | ||
|
||
public string Description | ||
=> "OpenClassicPropertiesDescription".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph | ||
=> new(themedIconStyle: "App.ThemedIcons.Properties"); | ||
|
||
public HotKey HotKey | ||
=> new(Keys.Enter, KeyModifiers.AltShift); | ||
|
||
public bool IsExecutable => | ||
context.PageType is not ContentPageTypes.Home && | ||
(context.HasSelection && context.SelectedItems.Count == 1 || | ||
!context.HasSelection && context.PageType is not ContentPageTypes.SearchResults); | ||
|
||
public OpenClassicPropertiesAction() | ||
{ | ||
context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync(object? parameter = null) | ||
{ | ||
if (context.HasSelection && context?.SelectedItem?.ItemPath is not null) | ||
ExecuteShellCommand(context.SelectedItem.ItemPath); | ||
else if (context?.Folder?.ItemPath is not null) | ||
ExecuteShellCommand(context.Folder.ItemPath); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private unsafe void ExecuteShellCommand(string itemPath) | ||
{ | ||
SHELLEXECUTEINFOW info = default; | ||
info.cbSize = (uint)Marshal.SizeOf(info); | ||
info.nShow = 5; // SW_SHOW | ||
info.fMask = 0x0000000C; | ||
|
||
var verb = "properties"; | ||
fixed (char* cVerb = verb) | ||
info.lpVerb = cVerb; | ||
|
||
fixed (char* lpFile = itemPath) | ||
info.lpFile = lpFile; | ||
|
||
PInvoke.ShellExecuteEx(ref info); | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.PageType): | ||
case nameof(IContentPageContext.HasSelection): | ||
case nameof(IContentPageContext.Folder): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.