using System; using Avalonia.Controls; using Avalonia.Native; namespace Avalonia { public static class AvaloniaNativePlatformExtensions { public static AppBuilder UseAvaloniaNative(this AppBuilder builder) { builder.UseWindowingSubsystem(() => { var platform = AvaloniaNativePlatform.Initialize( AvaloniaLocator.Current.GetService() ?? new AvaloniaNativePlatformOptions()); builder.AfterSetup (x=> { platform.SetupApplicationName(); platform.SetupApplicationMenuExporter(); }); }); return builder; } } /// /// OSX backend options. /// public class AvaloniaNativePlatformOptions { /// /// Deferred renderer would be used when set to true. Immediate renderer when set to false. The default value is true. /// /// /// Avalonia has two rendering modes: Immediate and Deferred rendering. /// Immediate re-renders the whole scene when some element is changed on the scene. Deferred re-renders only changed elements. /// public bool UseDeferredRendering { get; set; } = true; /// /// Enables new compositing rendering with UWP-like API /// public bool UseCompositor { get; set; } = true; /// /// Determines whether to use GPU for rendering in your project. The default value is true. /// public bool UseGpu { get; set; } = true; /// /// Embeds popups to the window when set to true. The default value is false. /// public bool OverlayPopups { get; set; } /// /// This property should be used in case you want to build Avalonia OSX native part by yourself /// and make your Avalonia app run with it. The default value is null. /// public string AvaloniaNativeLibraryPath { get; set; } } // ReSharper disable once InconsistentNaming /// /// OSX front-end options. /// public class MacOSPlatformOptions { /// /// Determines whether to show your application in the dock when it runs. The default value is true. /// public bool ShowInDock { get; set; } = true; /// /// By default, Avalonia adds items like Quit, Hide to the OSX Application Menu. /// You can prevent Avalonia from adding those items to the OSX Application Menu with this property. The default value is false. /// public bool DisableDefaultApplicationMenuItems { get; set; } /// /// Gets or sets a value indicating whether the native macOS menu bar will be enabled for the application. /// public bool DisableNativeMenus { get; set; } public bool DisableSetProcessName { get; set; } /// /// Gets or sets a value indicating whether Avalonia can install its own AppDelegate. /// Disabling this can be useful in some scenarios like when running as a plugin inside an existing macOS application. /// public bool DisableAvaloniaAppDelegate { get; set; } } }