-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ae5187
commit 5fd51d7
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
// Global using directives | ||
|
||
global using Microsoft.Win32; |
This file contains 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 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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using Microsoft.Win32; | ||
|
||
public class Startup | ||
public class Startup | ||
{ | ||
public static void Add() | ||
{ | ||
|
This file contains 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,36 @@ | ||
public static class TrayIcon | ||
{ | ||
public static void Promoted() | ||
{ | ||
//C:\Users\SimonCropp\.dotnet\tools\DiffEngineTray.exe | ||
var profileDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
var exePath = Path.Combine(profileDirectory, @"dotnet\tools\DiffEngineTray.exe"); | ||
using var iconSettingsKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\NotifyIconSettings"); | ||
if (iconSettingsKey == null) | ||
{ | ||
DiffEngine.Logging.Write(@"NotifyIconSettings reg path returned null. Path: Control Panel\NotifyIconSettings"); | ||
return; | ||
} | ||
|
||
foreach (var subKeyName in iconSettingsKey.GetSubKeyNames()) | ||
{ | ||
using var iconKey = iconSettingsKey.OpenSubKey(subKeyName, true); | ||
if (iconKey == null) | ||
{ | ||
continue; | ||
} | ||
|
||
var valueNames = iconKey.GetValueNames(); | ||
if (!valueNames.Contains("ExecutablePath") || | ||
!string.Equals((string?) iconKey.GetValue("ExecutablePath"), exePath, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
continue; | ||
} | ||
|
||
iconKey.SetValue("IsPromoted", 1, RegistryValueKind.DWord); | ||
return; | ||
} | ||
|
||
DiffEngine.Logging.Write(@"DiffEngineTray.exe not found in NotifyIconSettings. Path: Control Panel\NotifyIconSettings"); | ||
} | ||
} |