Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added apps/windows/Cascade/Assets/app.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions apps/windows/Cascade/Cascade.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<RootNamespace>Cascade</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<!-- Embed the app icon into the .exe (Explorer / taskbar / Alt-Tab). -->
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
<Platforms>x64;arm64</Platforms>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
Expand Down Expand Up @@ -54,6 +56,10 @@
scripts/build-asset.ps1; replace with proper Square*Logo / Wide310x150
assets before shipping a real MSIX. -->
<ItemGroup>
<!-- Win32 .ico, also copied to output so the window can SetIcon at runtime. -->
<Content Include="Assets\app.ico" Condition="Exists('Assets\app.ico')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Square150x150Logo.png" Condition="Exists('Assets\Square150x150Logo.png')" />
<Content Include="Assets\Square44x44Logo.png" Condition="Exists('Assets\Square44x44Logo.png')" />
<Content Include="Assets\StoreLogo.png" Condition="Exists('Assets\StoreLogo.png')" />
Expand Down
16 changes: 16 additions & 0 deletions apps/windows/Cascade/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using Cascade.Services;
using Cascade.ViewModels;
using Microsoft.UI.Dispatching;
Expand All @@ -15,10 +16,25 @@ public sealed partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
SetWindowIcon();
ViewModel = new AppViewModel(DispatcherQueue.GetForCurrentThread());
Closed += (_, _) => ViewModel.Dispose();
}

/// <summary>
/// Set the title-bar / taskbar icon for this unpackaged window. The .exe
/// already embeds the icon via &lt;ApplicationIcon&gt; (Explorer/Alt-Tab),
/// but the live window needs it set explicitly through AppWindow.
/// </summary>
private void SetWindowIcon()
{
var iconPath = Path.Combine(AppContext.BaseDirectory, "Assets", "app.ico");
if (!File.Exists(iconPath)) return;
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hwnd);
Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId).SetIcon(iconPath);
}

/// <summary>
/// Slider raises ValueChanged on every motion frame; ignore the initial
/// load callback (where IntermediateValue == OldValue) so we don't
Expand Down
Loading