From c656d43c455cd993f9065aaee4c88f783edb9ad9 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:32:12 -0500 Subject: [PATCH] Requested changes --- .../Data/Factories/ShellContextFlyoutHelper.cs | 5 +++-- src/Files.App/Utils/Shell/Win32API.cs | 15 --------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs index 6894247b385ee..e8cb98f9796f0 100644 --- a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs +++ b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs @@ -12,6 +12,7 @@ using Vanara.PInvoke; using Windows.System; using Windows.UI.Core; +using static Vanara.PInvoke.Kernel32; namespace Files.App.Helpers { @@ -180,11 +181,11 @@ async Task InvokeShellMenuItemAsync(ContextMenu contextMenu, object? tag) switch (verb) { case "install" when isFont: - await Task.WhenAll(contextMenu.ItemsPath.Select(path => Win32API.InstallFont(path, false))); + await Win32API.InstallFontsAsync(contextMenu.ItemsPath.ToArray(), false); break; case "installAllUsers" when isFont: - await Task.WhenAll(contextMenu.ItemsPath.Select(path => Win32API.InstallFont(path, true))); + await Win32API.InstallFontsAsync(contextMenu.ItemsPath.ToArray(), true); break; case "mount": diff --git a/src/Files.App/Utils/Shell/Win32API.cs b/src/Files.App/Utils/Shell/Win32API.cs index 3e1c45b181e7d..3e46b658b48a3 100644 --- a/src/Files.App/Utils/Shell/Win32API.cs +++ b/src/Files.App/Utils/Shell/Win32API.cs @@ -850,21 +850,6 @@ public static async Task InstallInf(string filePath) } } - public static Task InstallFont(string fontFilePath, bool forAllUsers) - { - string fontDirectory = forAllUsers - ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Fonts") - : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "Windows", "Fonts"); - - string registryKey = forAllUsers - ? "HKLM:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" - : "HKCU:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; - - var destinationPath = Path.Combine(fontDirectory, Path.GetFileName(fontFilePath)); - - return RunPowershellCommandAsync($"-command \"Copy-Item '{fontFilePath}' '{fontDirectory}'; New-ItemProperty -Name '{Path.GetFileNameWithoutExtension(fontFilePath)}' -Path '{registryKey}' -PropertyType string -Value '{destinationPath}'\"", forAllUsers); - } - public static async Task InstallFontsAsync(string[] fontFilePaths, bool forAllUsers) { string fontDirectory = forAllUsers