Apply TornadoAce icon to WinUI window

This commit is contained in:
2026-06-09 13:57:26 +09:00
parent 8dbbe605e9
commit 0b4e2e023c
2 changed files with 28 additions and 1 deletions

View File

@@ -1,3 +1,8 @@
using Microsoft.UI.Windowing;
using System;
using System.IO;
using WinRT.Interop;
namespace TornadoAce_CJOnStyle
{
/// <summary>
@@ -28,6 +33,8 @@ namespace TornadoAce_CJOnStyle
Title = "TornadoAce CJ OnStyle CG Automation"
};
ApplyWindowIcon(window);
if (window.Content is not Frame rootFrame)
{
rootFrame = new Frame();
@@ -39,6 +46,24 @@ namespace TornadoAce_CJOnStyle
window.Activate();
}
private static void ApplyWindowIcon(Window targetWindow)
{
var iconPath = Path.Combine(AppContext.BaseDirectory, "Assets", "AppIcon.ico");
if (!File.Exists(iconPath))
{
return;
}
var windowHandle = WindowNative.GetWindowHandle(targetWindow);
if (windowHandle == IntPtr.Zero)
{
return;
}
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
AppWindow.GetFromWindowId(windowId)?.SetIcon(iconPath);
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>

View File

@@ -30,7 +30,9 @@
<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\AppIcon.ico" />
<Content Include="Assets\AppIcon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\LoginBroadcastControlRoom.png" />
<Content Include="Assets\TornadoAceAppIcon.png" />