diff --git a/src/SourceGit/Native/OS.cs b/src/SourceGit/Native/OS.cs index 7169d51f..2229ed18 100644 --- a/src/SourceGit/Native/OS.cs +++ b/src/SourceGit/Native/OS.cs @@ -3,8 +3,6 @@ using System.Diagnostics; using Avalonia; -// ReSharper disable InconsistentNaming - namespace SourceGit.Native { public static class OS @@ -29,27 +27,24 @@ namespace SourceGit.Native public static string FleetExecutableFile { get; set; } - public enum Platforms - { - Unknown = 0, - Windows = 1, - MacOS = 2, - Linux - } - - public static Platforms Platform => OperatingSystem.IsWindows() ? Platforms.Windows : OperatingSystem.IsMacOS() ? Platforms.MacOS : OperatingSystem.IsLinux() ? Platforms.Linux : Platforms.Unknown; - static OS() { - _backend = Platform switch + if (OperatingSystem.IsWindows()) { -#pragma warning disable CA1416 - Platforms.Windows => new Windows(), - Platforms.MacOS => new MacOS(), - Platforms.Linux => new Linux(), -#pragma warning restore CA1416 - _ => throw new Exception("Platform unsupported!!!") - }; + _backend = new Windows(); + } + else if (OperatingSystem.IsMacOS()) + { + _backend = new MacOS(); + } + else if (OperatingSystem.IsLinux()) + { + _backend = new Linux(); + } + else + { + throw new Exception("Platform unsupported!!!"); + } VSCodeExecutableFile = _backend.FindVSCode(); FleetExecutableFile = _backend.FindFleet(); @@ -95,7 +90,10 @@ namespace SourceGit.Native Process.Start(new ProcessStartInfo() { - WorkingDirectory = repo, FileName = VSCodeExecutableFile, Arguments = $"\"{repo}\"", UseShellExecute = false, + WorkingDirectory = repo, + FileName = VSCodeExecutableFile, + Arguments = $"\"{repo}\"", + UseShellExecute = false, }); } @@ -111,7 +109,10 @@ namespace SourceGit.Native Process.Start(new ProcessStartInfo() { - WorkingDirectory = repo, FileName = FleetExecutableFile, Arguments = $"\"{repo}\"", UseShellExecute = false, + WorkingDirectory = repo, + FileName = FleetExecutableFile, + Arguments = $"\"{repo}\"", + UseShellExecute = false, }); } } diff --git a/src/SourceGit/Native/Windows.cs b/src/SourceGit/Native/Windows.cs index ead733f1..3e6443d9 100644 --- a/src/SourceGit/Native/Windows.cs +++ b/src/SourceGit/Native/Windows.cs @@ -103,11 +103,21 @@ namespace SourceGit.Native public string FindVSCode() { + var root = Microsoft.Win32.RegistryKey.OpenBaseKey( + Microsoft.Win32.RegistryHive.LocalMachine, + Environment.Is64BitOperatingSystem ? Microsoft.Win32.RegistryView.Registry64 : Microsoft.Win32.RegistryView.Registry32); + + var vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1"); + if (vscode != null) + { + return vscode.GetValue("DisplayIcon") as string; + } + var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"); if (File.Exists(toolPath)) return toolPath; return string.Empty; } - + public string FindFleet() { var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe"); diff --git a/src/SourceGit/Resources/ExternalToolIcons/fleet.png b/src/SourceGit/Resources/ExternalToolIcons/fleet.png new file mode 100644 index 00000000..85e2fab0 Binary files /dev/null and b/src/SourceGit/Resources/ExternalToolIcons/fleet.png differ diff --git a/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg b/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg deleted file mode 100644 index 3ab51b6e..00000000 --- a/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SourceGit/Resources/ExternalToolIcons/vscode.png b/src/SourceGit/Resources/ExternalToolIcons/vscode.png new file mode 100644 index 00000000..1ee79ae1 Binary files /dev/null and b/src/SourceGit/Resources/ExternalToolIcons/vscode.png differ diff --git a/src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg b/src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg deleted file mode 100644 index 8d9e0b08..00000000 --- a/src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/SourceGit/SourceGit.csproj b/src/SourceGit/SourceGit.csproj index 9dbaa5c5..8a1b5a45 100644 --- a/src/SourceGit/SourceGit.csproj +++ b/src/SourceGit/SourceGit.csproj @@ -23,6 +23,7 @@ + @@ -44,7 +45,6 @@ - @@ -58,8 +58,4 @@ - - - - diff --git a/src/SourceGit/ViewModels/Repository.cs b/src/SourceGit/ViewModels/Repository.cs index 76444e6e..f8c25987 100644 --- a/src/SourceGit/ViewModels/Repository.cs +++ b/src/SourceGit/ViewModels/Repository.cs @@ -49,18 +49,6 @@ namespace SourceGit.ViewModels set; } = new AvaloniaList(); - [JsonIgnore] - public bool IsVSCodeFound - { - get => !string.IsNullOrEmpty(Native.OS.VSCodeExecutableFile); - } - - [JsonIgnore] - public bool IsFleetFound - { - get => !string.IsNullOrEmpty(Native.OS.FleetExecutableFile); - } - [JsonIgnore] public Models.GitFlow GitFlow { @@ -291,7 +279,7 @@ namespace SourceGit.ViewModels { Native.OS.OpenInVSCode(_fullpath); } - + public void OpenInFleet() { Native.OS.OpenInFleet(_fullpath); diff --git a/src/SourceGit/Views/Repository.axaml b/src/SourceGit/Views/Repository.axaml index 5518279c..6632d5c7 100644 --- a/src/SourceGit/Views/Repository.axaml +++ b/src/SourceGit/Views/Repository.axaml @@ -18,33 +18,33 @@ - - - - + + + + + + @@ -83,7 +83,7 @@ - - @@ -230,22 +230,22 @@ - + - + - - @@ -301,10 +301,10 @@ - @@ -318,10 +318,10 @@ -