Skip to content

Commit ed04b58

Browse files
authored
feat(ui): add Visual Studio icon to application (#4)
- Extract VS 2026 icon from devenv.exe for use in the app - Add ICO file for window/taskbar icon via AppWindow.SetIcon() - Add PNG file for system tray icon via TrayIconService - Update csproj to include icon assets Closes #1
1 parent d5be5a1 commit ed04b58

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/CodingWithCalvin.VSToolbox/App.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
3030
var windowId = Win32Interop.GetWindowIdFromWindow(hwnd);
3131
_appWindow = AppWindow.GetFromWindowId(windowId);
3232

33+
// Set the window/taskbar icon
34+
var iconPath = Path.Combine(AppContext.BaseDirectory, "Assets", "vs2026_icon.ico");
35+
if (File.Exists(iconPath))
36+
{
37+
_appWindow.SetIcon(iconPath);
38+
}
39+
3340
// Set up the main content
3441
var rootFrame = new Frame();
3542
rootFrame.NavigationFailed += OnNavigationFailed;
189 KB
Binary file not shown.
49.6 KB
Loading

src/CodingWithCalvin.VSToolbox/CodingWithCalvin.VSToolbox.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
<Content Include="Assets\Square44x44Logo.scale-200.png" />
3131
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
3232
<Content Include="Assets\StoreLogo.png" />
33+
<Content Include="Assets\vs2026_icon.png" />
34+
<Content Include="Assets\vs2026_icon.ico" />
3335
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
3436
</ItemGroup>
3537

src/CodingWithCalvin.VSToolbox/Services/TrayIconService.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,24 @@ public void Initialize(Window window)
4646

4747
private static Icon? GetAppIcon()
4848
{
49-
// Try to get the app's icon from the executable
50-
var exePath = Environment.ProcessPath;
51-
if (!string.IsNullOrEmpty(exePath) && File.Exists(exePath))
49+
// Try to load the VS icon from Assets
50+
var appDir = AppContext.BaseDirectory;
51+
var iconPath = Path.Combine(appDir, "Assets", "vs2026_icon.png");
52+
53+
if (File.Exists(iconPath))
5254
{
5355
try
5456
{
55-
return Icon.ExtractAssociatedIcon(exePath);
57+
using var bitmap = new Bitmap(iconPath);
58+
var hIcon = bitmap.GetHicon();
59+
return Icon.FromHandle(hIcon);
5660
}
5761
catch
5862
{
5963
// Fall back to default
6064
}
6165
}
66+
6267
return SystemIcons.Application;
6368
}
6469

0 commit comments

Comments
 (0)