feat(welcome): borderless fullscreen non-closable kiosk window
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user