コード例 #1
0
 public static T UseHeadless <T>(this T builder, AvaloniaHeadlessPlatformOptions opts)
     where T : AppBuilderBase <T>, new()
 {
     if (opts.UseHeadlessDrawing)
     {
         builder.UseRenderingSubsystem(HeadlessPlatformRenderInterface.Initialize, "Headless");
     }
     return(builder.UseWindowingSubsystem(() => AvaloniaHeadlessPlatform.Initialize(opts), "Headless"));
 }
コード例 #2
0
 internal static void Initialize(AvaloniaHeadlessPlatformOptions opts)
 {
     AvaloniaLocator.CurrentMutable
     .Bind <IPlatformThreadingInterface>().ToConstant(new HeadlessPlatformThreadingInterface())
     .Bind <IClipboard>().ToSingleton <HeadlessClipboardStub>()
     .Bind <ICursorFactory>().ToSingleton <HeadlessCursorFactoryStub>()
     .Bind <IPlatformSettings>().ToConstant(new HeadlessPlatformSettingsStub())
     .Bind <IPlatformIconLoader>().ToSingleton <HeadlessIconLoaderStub>()
     .Bind <IKeyboardDevice>().ToConstant(new KeyboardDevice())
     .Bind <IRenderLoop>().ToConstant(new RenderLoop())
     .Bind <IRenderTimer>().ToConstant(new RenderTimer(60))
     .Bind <IFontManagerImpl>().ToSingleton <HeadlessFontManagerStub>()
     .Bind <ITextShaperImpl>().ToSingleton <HeadlessTextShaperStub>()
     .Bind <IWindowingPlatform>().ToConstant(new HeadlessWindowingPlatform())
     .Bind <PlatformHotkeyConfiguration>().ToSingleton <PlatformHotkeyConfiguration>();
     if (opts.UseCompositor)
     {
         Compositor = new Compositor(AvaloniaLocator.Current.GetRequiredService <IRenderLoop>(), null);
     }
 }