Apply TornadoAce icon to WinUI window
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user