feat(welcome): borderless fullscreen non-closable kiosk window

This commit is contained in:
sysadmin
2026-06-09 14:39:30 +01:00
parent 2d8b651e34
commit 64ae04d56c
2 changed files with 35 additions and 1 deletions

View File

@@ -9,6 +9,14 @@ public partial class App : Application
protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new MainPage()) { Title = "SilverOS.Welcome.App" };
var window = new Window(new MainPage()) { Title = "SilverMetal Windows" };
#if WINDOWS
window.HandlerChanged += (s, e) =>
{
if (window.Handler?.PlatformView is Microsoft.UI.Xaml.Window native)
native.ApplyKioskChrome();
};
#endif
return window;
}
}

View File

@@ -0,0 +1,26 @@
#if WINDOWS
using Microsoft.UI.Windowing;
using Microsoft.UI;
using WinRT.Interop;
namespace SilverOS.Welcome.App;
public static class WindowExtensions
{
// Borderless, fullscreen, non-closable kiosk window.
public static void ApplyKioskChrome(this Microsoft.UI.Xaml.Window winuiWindow)
{
var hwnd = WindowNative.GetWindowHandle(winuiWindow);
var id = Win32Interop.GetWindowIdFromWindow(hwnd);
var appWindow = AppWindow.GetFromWindowId(id);
if (appWindow.Presenter is OverlappedPresenter p)
{
p.SetBorderAndTitleBar(false, false);
p.IsResizable = false; p.IsMaximizable = false; p.IsMinimizable = false;
}
appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
// Block the close box; the wizard exits by rebooting, not by closing.
appWindow.Closing += (s, e) => e.Cancel = true;
}
}
#endif