Upgrade to .NET 7

resolve #35
This commit is contained in:
Lin Yu Chieh (Victor) 2022-12-02 15:11:48 +08:00
parent f4dfbe2572
commit a4a3c9c031
7 changed files with 51 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<Import Project="..\..\..\..\Version.props" />
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<ProjectGuid>{64467D32-4786-4ADD-9B77-FBF3C965D3D1}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Community.PowerToys.Run.Plugin.Everything</RootNamespace>

View File

@ -51,6 +51,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (CanFileBeRunAsAdmin(record.Path))
{
contextMenus.Add(CreateRunAsAdminContextMenu(record));
contextMenus.Add(CreateRunAsUserContextMenu(record));
}
// https://learn.microsoft.com/en-us/windows/apps/design/style/segoe-ui-symbol-font
@ -169,6 +170,33 @@ namespace Community.PowerToys.Run.Plugin.Everything
};
}
// Function to add the context menu item to run as admin
private static ContextMenuResult CreateRunAsUserContextMenu(SearchResult record)
{
return new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = Properties.Resources.run_as_user,
Glyph = "\xE7EE",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.U,
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
try
{
Task.Run(() => Helper.RunAsUser(record.Path));
return true;
}
catch (Exception e)
{
Log.Exception($"Failed to run {record.Path} as different user, {e.Message}", e, MethodBase.GetCurrentMethod().DeclaringType);
return false;
}
},
};
}
// Function to test if the file can be run as admin
private bool CanFileBeRunAsAdmin(string path)
{

View File

@ -196,7 +196,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
/// <summary>
/// Looks up a localized string similar to Selected result can update query text. Helps Display additional info, but may change display results..
/// Looks up a localized string similar to Selected result can update query text. Helps display additional info, but may change display results..
/// </summary>
public static string QueryText_Description {
get {
@ -231,6 +231,15 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Run as different user (Ctrl+Shift+U).
/// </summary>
public static string run_as_user {
get {
return ResourceManager.GetString("run_as_user", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Copy.
/// </summary>

View File

@ -174,10 +174,13 @@
<data name="run_as_admin" xml:space="preserve">
<value>Run as administrator (Ctrl+Shift+Enter)</value>
</data>
<data name="run_as_user" xml:space="preserve">
<value>Run as different user (Ctrl+Shift+U)</value>
</data>
<data name="SwapCopy" xml:space="preserve">
<value>Copy</value>
</data>
<data name="SwapCopy_Description" xml:space="preserve">
<value>Set Ctrl+C to copy file/folder, Ctrl+Alt+C to copy path.</value>
</data>
</root>
</root>

View File

@ -162,6 +162,9 @@
<data name="run_as_admin" xml:space="preserve">
<value>以管理员身份运行 (Ctrl+Shift+Enter)</value>
</data>
<data name="run_as_user" xml:space="preserve">
<value>以不同的使用者身份运行(Ctrl+Shift+U)</value>
</data>
<data name="SwapCopy_Description" xml:space="preserve">
<value>使用 Ctrl+C 复制档案Ctrl+Alt+C 复制路径</value>
</data>

View File

@ -162,6 +162,9 @@
<data name="run_as_admin" xml:space="preserve">
<value>以系統管理員身分執行 (Ctrl+Shift+Enter)</value>
</data>
<data name="run_as_user" xml:space="preserve">
<value>以不同的使用者身份執行 (Ctrl+Shift+U)</value>
</data>
<data name="SwapCopy_Description" xml:space="preserve">
<value>使用 Ctrl+C 複製檔案Ctrl+Alt+C 複製路徑</value>
</data>

View File

@ -3,8 +3,8 @@
"ActionKeyword": "@",
"IsGlobal": true,
"Name": "Everything",
"Author": "Yu Chieh (Victor) Lin _0.64.1_",
"Version": "0.64.1",
"Author": "Yu Chieh (Victor) Lin _0.65.0_",
"Version": "0.65.0",
"Language": "csharp",
"Website": "https://github.com/Lin-ycv/EverythingPowerToys",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",