void DoInitialize(Action <AvaloniaNativeOptions> configure) { var opts = new AvaloniaNativeOptions(_factory); configure?.Invoke(opts); _factory.Initialize(); AvaloniaLocator.CurrentMutable .Bind <IPlatformThreadingInterface>().ToConstant(new PlatformThreadingInterface(_factory.CreatePlatformThreadingInterface())) .Bind <IStandardCursorFactory>().ToConstant(new CursorFactory(_factory.CreateCursorFactory())) .Bind <IPlatformIconLoader>().ToSingleton <IconLoader>() .Bind <IKeyboardDevice>().ToConstant(KeyboardDevice) .Bind <IMouseDevice>().ToConstant(MouseDevice) .Bind <IPlatformSettings>().ToConstant(this) .Bind <IWindowingPlatform>().ToConstant(this) .Bind <IClipboard>().ToConstant(new ClipboardImpl(_factory.CreateClipboard())) .Bind <IRenderLoop>().ToConstant(new RenderLoop()) .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60)) .Bind <ISystemDialogImpl>().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs())) .Bind <IWindowingPlatformGlFeature>().ToConstant(new GlPlatformFeature(_factory.ObtainGlFeature())) .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(InputModifiers.Windows)) .Bind <AvaloniaNativeOptions>().ToConstant(opts); }
void DoInitialize(AvaloniaNativePlatformOptions options) { _options = options; var applicationPlatform = new AvaloniaNativeApplicationPlatform(); _factory.Initialize(new GCHandleDeallocator(), applicationPlatform); if (_factory.MacOptions != null) { var macOpts = AvaloniaLocator.Current.GetService <MacOSPlatformOptions>() ?? new MacOSPlatformOptions(); _factory.MacOptions.SetShowInDock(macOpts.ShowInDock ? 1 : 0); } AvaloniaLocator.CurrentMutable .Bind <IPlatformThreadingInterface>() .ToConstant(new PlatformThreadingInterface(_factory.CreatePlatformThreadingInterface())) .Bind <ICursorFactory>().ToConstant(new CursorFactory(_factory.CreateCursorFactory())) .Bind <IPlatformIconLoader>().ToSingleton <IconLoader>() .Bind <IKeyboardDevice>().ToConstant(KeyboardDevice) .Bind <IPlatformSettings>().ToConstant(this) .Bind <IWindowingPlatform>().ToConstant(this) .Bind <IClipboard>().ToConstant(new ClipboardImpl(_factory.CreateClipboard())) .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60)) .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Meta, wholeWordTextActionModifiers: KeyModifiers.Alt)) .Bind <IMountedVolumeInfoProvider>().ToConstant(new MacOSMountedVolumeInfoProvider()) .Bind <IPlatformDragSource>().ToConstant(new AvaloniaNativeDragSource(_factory)) .Bind <IPlatformLifetimeEventsImpl>().ToConstant(applicationPlatform) .Bind <INativeApplicationCommands>().ToConstant(new MacOSNativeMenuCommands(_factory.CreateApplicationCommands())); var renderLoop = new RenderLoop(); AvaloniaLocator.CurrentMutable.Bind <IRenderLoop>().ToConstant(renderLoop); var hotkeys = AvaloniaLocator.Current.GetService <PlatformHotkeyConfiguration>(); hotkeys.MoveCursorToTheStartOfLine.Add(new KeyGesture(Key.Left, hotkeys.CommandModifiers)); hotkeys.MoveCursorToTheStartOfLineWithSelection.Add(new KeyGesture(Key.Left, hotkeys.CommandModifiers | hotkeys.SelectionModifiers)); hotkeys.MoveCursorToTheEndOfLine.Add(new KeyGesture(Key.Right, hotkeys.CommandModifiers)); hotkeys.MoveCursorToTheEndOfLineWithSelection.Add(new KeyGesture(Key.Right, hotkeys.CommandModifiers | hotkeys.SelectionModifiers)); if (_options.UseGpu) { try { _platformGl = new AvaloniaNativePlatformOpenGlInterface(_factory.ObtainGlDisplay()); AvaloniaLocator.CurrentMutable .Bind <IPlatformOpenGlInterface>().ToConstant(_platformGl) .Bind <IPlatformGpu>().ToConstant(_platformGl); } catch (Exception) { // ignored } } if (_options.UseDeferredRendering && _options.UseCompositor) { Compositor = new Compositor(renderLoop, _platformGl); } }