From affd240a347ad8e57a334f33e7b8389eecbd7132 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 8 Jun 2026 21:53:10 -0700 Subject: [PATCH 001/196] Add sleep timer option for the headless platform (#21423) * Add ShouldRenderOnUIThread//Fps options to the AvaloniaHeadlessPlatformOptions, allowing SleepLoopRenderTimer to be enabled * Don't throw from ForceRenderTimerTick * Run DispatcherFrame on RequestCommitAsync, when HeadlessRenderTimer is not available * This method apparently was public --- .../AvaloniaHeadlessPlatform.cs | 105 +++++++++--------- .../Avalonia.Headless/HeadlessRenderTimer.cs | 40 +++++++ 2 files changed, 95 insertions(+), 50 deletions(-) create mode 100644 src/Headless/Avalonia.Headless/HeadlessRenderTimer.cs diff --git a/src/Headless/Avalonia.Headless/AvaloniaHeadlessPlatform.cs b/src/Headless/Avalonia.Headless/AvaloniaHeadlessPlatform.cs index 8e44942d32..838301a6b5 100644 --- a/src/Headless/Avalonia.Headless/AvaloniaHeadlessPlatform.cs +++ b/src/Headless/Avalonia.Headless/AvaloniaHeadlessPlatform.cs @@ -1,64 +1,22 @@ using System; -using System.Diagnostics; -using Avalonia.Controls.Platform; -using Avalonia.Reactive; using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Rendering.Composition; -using Avalonia.Threading; using System.Collections.Generic; +using Avalonia.Threading; namespace Avalonia.Headless { public static class AvaloniaHeadlessPlatform { internal static Compositor? Compositor { get; private set; } - private static RenderTimer? s_renderTimer; - - private class RenderTimer : DefaultRenderTimer - { - private readonly int _framesPerSecond; - private Action? _forceTick; - protected override IDisposable StartCore(Action tick) - { - var st = Stopwatch.StartNew(); - _forceTick = () => tick(st.Elapsed); - - var timer = new DispatcherTimer(DispatcherPriority.UiThreadRender) - { - Interval = TimeSpan.FromSeconds(1.0 / _framesPerSecond), - Tag = "HeadlessRenderTimer" - }; - timer.Tick += (s, e) => tick(st.Elapsed); - timer.Start(); - - return Disposable.Create(() => - { - _forceTick = null; - timer.Stop(); - }); - } + private static IRenderTimer? s_renderTimer; - public RenderTimer(int framesPerSecond) : base(framesPerSecond) - { - _framesPerSecond = framesPerSecond; - } - - public override bool RunsInBackground => false; - - public void ForceTick() => _forceTick?.Invoke(); - } - - private class HeadlessWindowingPlatform : IWindowingPlatform + private class HeadlessWindowingPlatform(PixelFormat frameBufferFormat) : IWindowingPlatform { - readonly PixelFormat _frameBufferFormat; - public HeadlessWindowingPlatform(PixelFormat frameBufferFormat) - { - _frameBufferFormat = frameBufferFormat; - } - public IWindowImpl CreateWindow() => new HeadlessWindowImpl(false, _frameBufferFormat); + public IWindowImpl CreateWindow() => new HeadlessWindowImpl(false, frameBufferFormat); public ITopLevelImpl CreateEmbeddableTopLevel() => CreateEmbeddableWindow(); public IWindowImpl CreateEmbeddableWindow() => throw new PlatformNotSupportedException(); @@ -73,12 +31,16 @@ namespace Avalonia.Headless } } } - + internal static void Initialize(AvaloniaHeadlessPlatformOptions opts) { var clipboardImpl = new HeadlessClipboardImplStub(); var clipboard = new Clipboard(clipboardImpl); + s_renderTimer = opts.ShouldRenderOnUIThread + ? new HeadlessRenderTimer(opts.Fps) + : new SleepLoopRenderTimer(opts.Fps); + AvaloniaLocator.CurrentMutable .Bind().ToConstant(clipboardImpl) .Bind().ToConstant(clipboard) @@ -86,7 +48,7 @@ namespace Avalonia.Headless .Bind().ToSingleton() .Bind().ToSingleton() .Bind().ToConstant(new KeyboardDevice()) - .Bind().ToConstant(Rendering.RenderLoop.FromTimer(s_renderTimer = new RenderTimer(60))) + .Bind().ToConstant(Rendering.RenderLoop.FromTimer(s_renderTimer)) .Bind().ToConstant(new HeadlessWindowingPlatform(opts.FrameBufferFormat)) .Bind().ToSingleton() .Bind().ToConstant(new KeyGestureFormatInfo(new Dictionary() { })); @@ -100,15 +62,58 @@ namespace Avalonia.Headless /// Count of frames to be ticked on the timer. public static void ForceRenderTimerTick(int count = 1) { - for (var c = 0; c < count; c++) - s_renderTimer?.ForceTick(); + if (s_renderTimer is HeadlessRenderTimer timer) + { + for (var c = 0; c < count; c++) + { + timer.ForceTick(); + } + } + else + { + if (Compositor is not { } compositor) + { + throw new InvalidOperationException("Compositor is not initialized."); + } + var frame = new DispatcherFrame(); + var task = compositor.RequestCommitAsync(); + task.ContinueWith(static (_, s) => ((DispatcherFrame)s!).Continue = false, frame); + Dispatcher.CurrentDispatcher.PushFrame(frame); + task.GetAwaiter().GetResult(); + } } } + /// + /// Options for configuring the Avalonia headless platform. + /// public class AvaloniaHeadlessPlatformOptions { + /// + /// Gets or sets the number of frames per second at which the renderer should run. + /// Default 60. + /// + public int Fps { get; set; } = 60; + + /// + /// Render directly on the UI thread instead of using a dedicated render thread. + /// This can be usable if your device doesn't have multiple cores to begin with. + /// This setting is false by default. + /// + public bool ShouldRenderOnUIThread { get; set; } = true; + + /// + /// Gets or sets a value indicating whether to use headless drawing mode, which allows rendering without creating an actual window. + /// + /// + /// Disable this option if you are using Avalonia.Skia or another drawing backend. + /// public bool UseHeadlessDrawing { get; set; } = true; + + /// + /// Gets or sets the pixel format to be used for the headless Window framebuffers. + /// public PixelFormat FrameBufferFormat { get; set; } = PixelFormat.Rgba8888; } diff --git a/src/Headless/Avalonia.Headless/HeadlessRenderTimer.cs b/src/Headless/Avalonia.Headless/HeadlessRenderTimer.cs new file mode 100644 index 0000000000..6cbbd3d425 --- /dev/null +++ b/src/Headless/Avalonia.Headless/HeadlessRenderTimer.cs @@ -0,0 +1,40 @@ +using System; +using System.Diagnostics; +using Avalonia.Reactive; +using Avalonia.Rendering; +using Avalonia.Threading; + +namespace Avalonia.Headless; + +/// +/// A render timer implementation for headless environments that uses a DispatcherTimer to schedule ticks on the UI thread. +/// Can be controlled with method. +/// +internal class HeadlessRenderTimer(int framesPerSecond) : DefaultRenderTimer(framesPerSecond) +{ + private readonly int _framesPerSecond = framesPerSecond; + private Action? _forceTick; + protected override IDisposable StartCore(Action tick) + { + var st = Stopwatch.StartNew(); + _forceTick = () => tick(st.Elapsed); + + var timer = new DispatcherTimer(DispatcherPriority.UiThreadRender) + { + Interval = TimeSpan.FromSeconds(1.0 / _framesPerSecond), + Tag = "HeadlessRenderTimer" + }; + timer.Tick += (s, e) => tick(st.Elapsed); + timer.Start(); + + return Disposable.Create(() => + { + _forceTick = null; + timer.Stop(); + }); + } + + public override bool RunsInBackground => false; + + public void ForceTick() => _forceTick?.Invoke(); +} From 16cd5ff650e48a8d3948b2604b7389a34f5161d8 Mon Sep 17 00:00:00 2001 From: Tim Miller Date: Tue, 9 Jun 2026 21:28:57 +0900 Subject: [PATCH 002/196] [WinUI] Create Avalonia.WinUI for initial WinUI embed support (#21430) * Init 1 Init 2 Init 3 Init 4 Init 5 Add Windows SDK * Add WinUI to slnx * Update sample * Add clipboard support * Only handle text down if Avalonia didn't first * Start WinUIEmbedSample.csproj * Migrate from Avalonia.WinUI to Avalonia.Win32 * Input handling * Update sample * Hover * Update sample * IME Fixes * Fix keyscan * Update sample * Add cursor support * Update samples * Dispose _mouseDevice * Implement Drag Source (And fix logging) * Update samples * Update clipboard sample * Fix Focus/Tabs * Peer Proxy * Cleanup * Cleanup * Fix proj for WinUI * Refactor log * Fix proj * Remove internal using * try/finally contextLock * Remove systemAIModels * Fix IME * Cleanup * More IME changes * Update comment * Update logic * Handle Win32 Cursors * Fix AOT * Update description * Remove test code * Fix sample --- Avalonia.slnx | 9 + Directory.Packages.props | 2 + build/TargetFrameworks.props | 1 + dirs.proj | 6 + samples/ControlGallery.WinUI/App.xaml | 16 + samples/ControlGallery.WinUI/App.xaml.cs | 40 + .../Assets/LockScreenLogo.scale-200.png | Bin 0 -> 432 bytes .../Assets/SplashScreen.scale-200.png | Bin 0 -> 5372 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 0 -> 1755 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 0 -> 637 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 0 -> 283 bytes .../ControlGallery.WinUI/Assets/StoreLogo.png | Bin 0 -> 456 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 0 -> 2097 bytes .../ControlGallery.WinUI.csproj | 67 ++ samples/ControlGallery.WinUI/MainWindow.xaml | 15 + .../ControlGallery.WinUI/MainWindow.xaml.cs | 11 + .../ControlGallery.WinUI/Package.appxmanifest | 51 + .../Properties/launchSettings.json | 10 + samples/ControlGallery.WinUI/app.manifest | 19 + samples/WinUIEmbedSample/App.xaml | 14 + samples/WinUIEmbedSample/App.xaml.cs | 40 + samples/WinUIEmbedSample/AvaloniaApp.axaml | 7 + samples/WinUIEmbedSample/AvaloniaApp.axaml.cs | 13 + samples/WinUIEmbedSample/EmbeddedView.axaml | 228 +++++ .../WinUIEmbedSample/EmbeddedView.axaml.cs | 183 ++++ samples/WinUIEmbedSample/MainWindow.xaml | 114 +++ samples/WinUIEmbedSample/MainWindow.xaml.cs | 175 ++++ samples/WinUIEmbedSample/Package.appxmanifest | 51 + .../Properties/launchSettings.json | 10 + .../WinUIEmbedSample/WinUIEmbedSample.csproj | 66 ++ samples/WinUIEmbedSample/app.manifest | 16 + src/Avalonia.Base/Avalonia.Base.csproj | 1 + src/Avalonia.Base/Logging/LogArea.cs | 5 + .../Avalonia.Win32/Avalonia.Win32.csproj | 1 + .../OpenGl/Angle/SwapChainGlSurface.cs | 252 +++++ .../Avalonia.Win32/SwapChainTopLevelImpl.cs | 122 +++ .../AvaloniaSwapChainPanelAutomationPeer.cs | 143 +++ .../AvaloniaToXamlPeerProxy.ExpandCollapse.cs | 29 + .../AvaloniaToXamlPeerProxy.Invoke.cs | 9 + .../AvaloniaToXamlPeerProxy.RangeValue.cs | 16 + .../AvaloniaToXamlPeerProxy.Scroll.cs | 33 + .../AvaloniaToXamlPeerProxy.Selection.cs | 51 + .../AvaloniaToXamlPeerProxy.Toggle.cs | 27 + .../AvaloniaToXamlPeerProxy.Value.cs | 13 + .../Automation/AvaloniaToXamlPeerProxy.cs | 141 +++ .../Automation/ControlTypeMap.cs | 52 + .../Avalonia.WinUI/Avalonia.WinUI.csproj | 30 + .../Avalonia.WinUI/AvaloniaSwapChainPanel.cs | 915 ++++++++++++++++++ .../Avalonia.WinUI/WinUICursorFactory.cs | 91 ++ src/Windows/Avalonia.WinUI/WinUIDragSource.cs | 42 + src/Windows/Avalonia.WinUI/WinUIKeyInterop.cs | 62 ++ .../Avalonia.WinUI/WinUITextInputMethod.cs | 384 ++++++++ 52 files changed, 3583 insertions(+) create mode 100644 samples/ControlGallery.WinUI/App.xaml create mode 100644 samples/ControlGallery.WinUI/App.xaml.cs create mode 100644 samples/ControlGallery.WinUI/Assets/LockScreenLogo.scale-200.png create mode 100644 samples/ControlGallery.WinUI/Assets/SplashScreen.scale-200.png create mode 100644 samples/ControlGallery.WinUI/Assets/Square150x150Logo.scale-200.png create mode 100644 samples/ControlGallery.WinUI/Assets/Square44x44Logo.scale-200.png create mode 100644 samples/ControlGallery.WinUI/Assets/Square44x44Logo.targetsize-24_altform-unplated.png create mode 100644 samples/ControlGallery.WinUI/Assets/StoreLogo.png create mode 100644 samples/ControlGallery.WinUI/Assets/Wide310x150Logo.scale-200.png create mode 100644 samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj create mode 100644 samples/ControlGallery.WinUI/MainWindow.xaml create mode 100644 samples/ControlGallery.WinUI/MainWindow.xaml.cs create mode 100644 samples/ControlGallery.WinUI/Package.appxmanifest create mode 100644 samples/ControlGallery.WinUI/Properties/launchSettings.json create mode 100644 samples/ControlGallery.WinUI/app.manifest create mode 100644 samples/WinUIEmbedSample/App.xaml create mode 100644 samples/WinUIEmbedSample/App.xaml.cs create mode 100644 samples/WinUIEmbedSample/AvaloniaApp.axaml create mode 100644 samples/WinUIEmbedSample/AvaloniaApp.axaml.cs create mode 100644 samples/WinUIEmbedSample/EmbeddedView.axaml create mode 100644 samples/WinUIEmbedSample/EmbeddedView.axaml.cs create mode 100644 samples/WinUIEmbedSample/MainWindow.xaml create mode 100644 samples/WinUIEmbedSample/MainWindow.xaml.cs create mode 100644 samples/WinUIEmbedSample/Package.appxmanifest create mode 100644 samples/WinUIEmbedSample/Properties/launchSettings.json create mode 100644 samples/WinUIEmbedSample/WinUIEmbedSample.csproj create mode 100644 samples/WinUIEmbedSample/app.manifest create mode 100644 src/Windows/Avalonia.Win32/OpenGl/Angle/SwapChainGlSurface.cs create mode 100644 src/Windows/Avalonia.Win32/SwapChainTopLevelImpl.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaSwapChainPanelAutomationPeer.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.ExpandCollapse.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.Invoke.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.RangeValue.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.Scroll.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.Selection.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.Toggle.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.Value.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/AvaloniaToXamlPeerProxy.cs create mode 100644 src/Windows/Avalonia.WinUI/Automation/ControlTypeMap.cs create mode 100644 src/Windows/Avalonia.WinUI/Avalonia.WinUI.csproj create mode 100644 src/Windows/Avalonia.WinUI/AvaloniaSwapChainPanel.cs create mode 100644 src/Windows/Avalonia.WinUI/WinUICursorFactory.cs create mode 100644 src/Windows/Avalonia.WinUI/WinUIDragSource.cs create mode 100644 src/Windows/Avalonia.WinUI/WinUIKeyInterop.cs create mode 100644 src/Windows/Avalonia.WinUI/WinUITextInputMethod.cs diff --git a/Avalonia.slnx b/Avalonia.slnx index 80b4042e7a..dba476ed4a 100644 --- a/Avalonia.slnx +++ b/Avalonia.slnx @@ -65,6 +65,10 @@ + + + + @@ -84,6 +88,10 @@ + + + + @@ -178,6 +186,7 @@ + diff --git a/Directory.Packages.props b/Directory.Packages.props index f4e677d631..cac3db9cc9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -31,6 +31,8 @@ + + diff --git a/build/TargetFrameworks.props b/build/TargetFrameworks.props index 96541e7ecf..a380009e23 100644 --- a/build/TargetFrameworks.props +++ b/build/TargetFrameworks.props @@ -8,6 +8,7 @@ $(AvsCurrentTargetFramework)-ios26.0 $(AvsCurrentTargetFramework)-tvos26.0 $(AvsCurrentTargetFramework)-browser + $(AvsCurrentTargetFramework)-windows10.0.19041.0 net8.0 diff --git a/dirs.proj b/dirs.proj index 20df84439e..43c2518f78 100644 --- a/dirs.proj +++ b/dirs.proj @@ -14,12 +14,18 @@ + + + + + + diff --git a/samples/ControlGallery.WinUI/App.xaml b/samples/ControlGallery.WinUI/App.xaml new file mode 100644 index 0000000000..88b20eca37 --- /dev/null +++ b/samples/ControlGallery.WinUI/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/samples/ControlGallery.WinUI/App.xaml.cs b/samples/ControlGallery.WinUI/App.xaml.cs new file mode 100644 index 0000000000..5d26d06383 --- /dev/null +++ b/samples/ControlGallery.WinUI/App.xaml.cs @@ -0,0 +1,40 @@ +using global::Avalonia; +using global::Avalonia.Controls; +using global::Avalonia.Controls.ApplicationLifetimes; +using global::Avalonia.Skia; +using global::Avalonia.Win32; +using WinUIApplication = Microsoft.UI.Xaml.Application; +using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs; +using Window = Microsoft.UI.Xaml.Window; + +namespace ControlGallery.WinUI +{ + public partial class App : WinUIApplication + { + private Window? _window; + + internal static SingleViewLifetime Lifetime { get; } = new(); + + public App() + { + InitializeComponent(); + } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + AppBuilder.Configure() + .UseWin32() + .UseSkia() + .UseHarfBuzz() + .SetupWithLifetime(Lifetime); + + _window = new MainWindow(); + _window.Activate(); + } + } + + internal sealed class SingleViewLifetime : ISingleViewApplicationLifetime + { + public Control? MainView { get; set; } + } +} diff --git a/samples/ControlGallery.WinUI/Assets/LockScreenLogo.scale-200.png b/samples/ControlGallery.WinUI/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..7440f0d4bf7c7e26e4e36328738c68e624ee851e GIT binary patch literal 432 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(FqV6|IEGZ*x-#9g>~Mkr+x6^F zy~CDX2QIMs&Gcs3RnRBoxBA!*(Mfw0KTCYuYk0WlEIV>qBmPl! zq4ukrvfADX@#p8fbLY(H47N+k`FZ(FZh?cDro7>{8mkBO3>^oaIx`3!Jl)Qq)HI!+ z(S=1{o~eT)&W^=Ea8C`-17(Jv5(nHFJ{dOjGdxLVkY_y6&S1whfuFI4MM0kF0f&cO zPDVpV%nz;Id$>+0Ga5e9625-JcI)oq=#Pa3p^>8BB}21BUw@eN!-6@w%X+^`+Vn?! zryu|3T>kVWNBYyBc=7Y6H#s1Ah!OI_nezW zXTqOdkv2Az6KKBV=$yHdF^R3Fqw(TZEoNSZX>reXJ#bwX42%f|Pgg&ebxsLQ010xn AssI20 literal 0 HcmV?d00001 diff --git a/samples/ControlGallery.WinUI/Assets/SplashScreen.scale-200.png b/samples/ControlGallery.WinUI/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..32f486a86792a5e34cd9a8261b394c49b48f86be GIT binary patch literal 5372 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 literal 0 HcmV?d00001 diff --git a/samples/ControlGallery.WinUI/Assets/Square44x44Logo.scale-200.png b/samples/ControlGallery.WinUI/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..f713bba67f551ef91020b75716a4dc8ebd744b1c GIT binary patch literal 637 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8kjIJFu8cTIEGZ*dUI*J;2{SImxtDO zm%3!R$UazoY}x{$j0P5ABYXWr(l=jxJ6ps1W{tV=^>{Dl><3nv3A}sm=EZ)#l3`NR zpZda3^rNox*D1%NC98Z~L*6zipLw~Gxn&(Y-;KmJ+aR6eLabU-L#y8HW%7P-E_-VlLqIabbHPHKT*)fT@9iWJ7iWgOT9%0}Lrj>lztPxWq6sPw3pi z#-<=#$jjrP_DD*i!RLsn0mIA=>4~N)IMYWIf=j%-zuKCdMG%tHYot70D1| zvWa0wMhauW#S>1CnI_;>!1Q3zMA17@DOVq{MQ+{U7^a&yA+%dMCG;WNPV0i;w$tu; zX^b}UKziPM)(<;)ruW;-`)bBN+rQNM*Zs_>?n$|FVFo-e*PZb*@U7VAd+tHb4e?=Blc~}S6K)wL}r*Gf`BM#QB z+y>N$mCswb4d{^{S9v_!eQj4fTRMOwOCi?lSk9%<=vAz}jM-*PQtH@Odn1LZcd^j#o> hW$4xn+CT+ep9lJ{OAO?njobhL002ovPDHLkV1nYebbkN< literal 0 HcmV?d00001 diff --git a/samples/ControlGallery.WinUI/Assets/StoreLogo.png b/samples/ControlGallery.WinUI/Assets/StoreLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..a4586f26bdf7841cad10f39cdffe2aca3af252c1 GIT binary patch literal 456 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2o;fF!p=8IEGZ*dUM0H=rDtTTVkd2 z(%lbKn@VS_lUaADVB&;Z6F#LM+mPsa?e>FnHo;HND^!P`-lX%BH~FOg%y&x+t*x!? zg$#_1A1kgsSvO(fw`bOmo;lrJX8byO1j^gf7qohR%mmt z@L)WX;>gqgK|tWJvQ5j;4;=gt4HXVKSMYRv5RhY5vS~TqfK_NAP*r{h!!g^BZ;w4r z7CGdsai)y;fJQc`7{Zc2b==h%o`Op$|bg6a&nL{*m7-=0>k4M4-PXlU;G-?%*(*g>iFt^ U$m#7DfHB12>FVdQ&MBb@0G`#n8vpc0sq%A~kJcD9FY~qQRMt?ZR3YyDZt}Od;|mgpc{2dv9AHF){kXU%k({ z=Y8JidEayHTkG@twPZ|U3_^%3ct-OgLSiFAqDN!|tbCX@c@?4P`2x*TMK!+Q4b?k0 ziW7!!KF6dPWcF<%I|iznM~`QJ_V7sHGV_D`dhgpA9Vd@&X}ErK+j~_rdv;Bp?OA@a zFXOk7eWOJe5NcK;6h$FaM&7JxNc#-@QTwzW6x#d_zmQNkz5) zPI;kh;3d;5UCJU+9a(cOxX(|edWoOiAEdGU#kPJ&xnc2||3vDbuhBCkj-pb0as$Zl z5;}4n=**n6(1g`JEtSy;SG6X;#-F~Oz3lESG2b5`j@wAwY4Yp<=4Xeb>iH=6aicF?DxD&q{`!&}ct zBI)aycwuobQAf&678Uf+Mmh-@9RUhyH~>?w0dixO0#jZjEc9R^=5NZw=|a(kcB?9^ zfnTiEFXp-q#B;Tn>(O%$A*ud^Rg&eVH6Y_5Y%!E39RR&s?XpG`gKwU!6FE1 z7X)DC7)*(5g}lh`4`{i~DZcWupZI`K)_4P)VE{@gc7@Xsd^86zl~_mOYH?I4!aGeX z^E(_=L6?PgveDQ+r%P@UISEXrkn`LHJZ##+!-anV>6h)IkKp;E@p8+3&(5%kS2)ld*J*rJccZM0iyaAx7+F~GW1UWFK&3X$PE1^}NH zgAG9ck5K!{07OwU@j@Do>TbH=CDEo#4m0cEyAuXy_<&jlzJVcKweSJ5 z&=q~iIn18$w8yb=rmEmHxVEUA^?RwnB?6Qlp1os8@*dWTGL2bhzZ!s*xqScR?EPL` zo(JwNdKUUYy7GtvZ3asXm)cgFvCx9EmAi;|w=a0iGiv%%VYKh`P0Wma4y`Xyx|T~( zAmfGbgbEEC7)j8b@WA@+5W3a61HJXC1dX@6_T|Czk0I0zBk%tnW~()VWITGI!`$c< gARL?UBrYYkwoDw4eo*CrzXGTrZ@;GF>596)00d&n@&Et; literal 0 HcmV?d00001 diff --git a/samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj b/samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj new file mode 100644 index 0000000000..4b3d246aaf --- /dev/null +++ b/samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj @@ -0,0 +1,67 @@ + + + WinExe + $(AvsCurrentWinUITargetFramework) + 10.0.17763.0 + ControlGallery.WinUI + app.manifest + x86;x64;ARM64 + win-x86;win-x64;win-arm64 + win-$(Platform).pubxml + true + false + true + enable + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + False + True + False + True + + \ No newline at end of file diff --git a/samples/ControlGallery.WinUI/MainWindow.xaml b/samples/ControlGallery.WinUI/MainWindow.xaml new file mode 100644 index 0000000000..9595ef8253 --- /dev/null +++ b/samples/ControlGallery.WinUI/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/samples/ControlGallery.WinUI/MainWindow.xaml.cs b/samples/ControlGallery.WinUI/MainWindow.xaml.cs new file mode 100644 index 0000000000..7f9b40b82e --- /dev/null +++ b/samples/ControlGallery.WinUI/MainWindow.xaml.cs @@ -0,0 +1,11 @@ +namespace ControlGallery.WinUI +{ + public sealed partial class MainWindow : Microsoft.UI.Xaml.Window + { + public MainWindow() + { + InitializeComponent(); + AvaloniaPanel.Content = App.Lifetime.MainView; + } + } +} diff --git a/samples/ControlGallery.WinUI/Package.appxmanifest b/samples/ControlGallery.WinUI/Package.appxmanifest new file mode 100644 index 0000000000..fcd91fc1ac --- /dev/null +++ b/samples/ControlGallery.WinUI/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + ControlGallery.WinUI + drasticactions + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlGallery.WinUI/Properties/launchSettings.json b/samples/ControlGallery.WinUI/Properties/launchSettings.json new file mode 100644 index 0000000000..ddb3c41a5a --- /dev/null +++ b/samples/ControlGallery.WinUI/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "ControlGallery.WinUI (Package)": { + "commandName": "MsixPackage" + }, + "ControlGallery.WinUI (Unpackaged)": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/samples/ControlGallery.WinUI/app.manifest b/samples/ControlGallery.WinUI/app.manifest new file mode 100644 index 0000000000..e6d75d93fc --- /dev/null +++ b/samples/ControlGallery.WinUI/app.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + \ No newline at end of file diff --git a/samples/WinUIEmbedSample/App.xaml b/samples/WinUIEmbedSample/App.xaml new file mode 100644 index 0000000000..0bfa0c7b64 --- /dev/null +++ b/samples/WinUIEmbedSample/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/samples/WinUIEmbedSample/App.xaml.cs b/samples/WinUIEmbedSample/App.xaml.cs new file mode 100644 index 0000000000..6524572edd --- /dev/null +++ b/samples/WinUIEmbedSample/App.xaml.cs @@ -0,0 +1,40 @@ +using global::Avalonia; +using global::Avalonia.Controls; +using global::Avalonia.Controls.ApplicationLifetimes; +using global::Avalonia.Skia; +using global::Avalonia.Win32; +using WinUIApplication = Microsoft.UI.Xaml.Application; +using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs; +using Window = Microsoft.UI.Xaml.Window; + +namespace WinUIEmbedSample +{ + public partial class App : WinUIApplication + { + private Window? _window; + + internal static SingleViewLifetime Lifetime { get; } = new(); + + public App() + { + InitializeComponent(); + } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + AppBuilder.Configure() + .UseWin32() + .UseSkia() + .UseHarfBuzz() + .SetupWithLifetime(Lifetime); + + _window = new MainWindow(); + _window.Activate(); + } + } + + internal sealed class SingleViewLifetime : ISingleViewApplicationLifetime + { + public Control? MainView { get; set; } + } +} diff --git a/samples/WinUIEmbedSample/AvaloniaApp.axaml b/samples/WinUIEmbedSample/AvaloniaApp.axaml new file mode 100644 index 0000000000..03c11e5146 --- /dev/null +++ b/samples/WinUIEmbedSample/AvaloniaApp.axaml @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/WinUIEmbedSample/AvaloniaApp.axaml.cs b/samples/WinUIEmbedSample/AvaloniaApp.axaml.cs new file mode 100644 index 0000000000..854a7bd186 --- /dev/null +++ b/samples/WinUIEmbedSample/AvaloniaApp.axaml.cs @@ -0,0 +1,13 @@ +using global::Avalonia; +using global::Avalonia.Markup.Xaml; +using AvApplication = global::Avalonia.Application; + +namespace WinUIEmbedSample; + +public partial class AvaloniaApp : AvApplication +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/samples/WinUIEmbedSample/EmbeddedView.axaml b/samples/WinUIEmbedSample/EmbeddedView.axaml new file mode 100644 index 0000000000..9cfbd4cb1b --- /dev/null +++ b/samples/WinUIEmbedSample/EmbeddedView.axaml @@ -0,0 +1,228 @@ + + + + + + +