Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 committed Feb 7, 2024
1 parent a16adba commit c656d43
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Vanara.PInvoke;
using Windows.System;
using Windows.UI.Core;
using static Vanara.PInvoke.Kernel32;

namespace Files.App.Helpers
{
Expand Down Expand Up @@ -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":
Expand Down
15 changes: 0 additions & 15 deletions src/Files.App/Utils/Shell/Win32API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -850,21 +850,6 @@ public static async Task<bool> 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
Expand Down

0 comments on commit c656d43

Please sign in to comment.