Пример #1
0
        internal WindowBaseImpl(AvaloniaNativePlatformOptions opts, AvaloniaNativePlatformOpenGlInterface glFeature)
        {
            _gpu = opts.UseGpu && glFeature != null;
            _deferredRendering = opts.UseDeferredRendering;

            _keyboard      = AvaloniaLocator.Current.GetService <IKeyboardDevice>();
            _mouse         = new MouseDevice();
            _cursorFactory = AvaloniaLocator.Current.GetService <IStandardCursorFactory>();
        }
Пример #2
0
        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>();

                _factory.MacOptions.SetShowInDock(macOpts?.ShowInDock != false ? 1 : 0);
                _factory.MacOptions.SetDisableDefaultApplicationMenuItems(
                    macOpts?.DisableDefaultApplicationMenuItems == true ? 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 <IRenderLoop>().ToConstant(new RenderLoop())
            .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
            .Bind <ISystemDialogImpl>().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs()))
            .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);

            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
                {
                    AvaloniaLocator.CurrentMutable.Bind <IPlatformOpenGlInterface>()
                    .ToConstant(_platformGl = new AvaloniaNativePlatformOpenGlInterface(_factory.ObtainGlDisplay()));
                }
                catch (Exception)
                {
                    // ignored
                }
            }
        }
Пример #3
0
        internal WindowBaseImpl(IAvaloniaNativeFactory factory, AvaloniaNativePlatformOptions opts,
                                AvaloniaNativePlatformOpenGlInterface glFeature)
        {
            _factory           = factory;
            _gpu               = opts.UseGpu && glFeature != null;
            _deferredRendering = opts.UseDeferredRendering;

            _keyboard       = AvaloniaLocator.Current.GetService <IKeyboardDevice>();
            _mouse          = new MouseDevice();
            _cursorFactory  = AvaloniaLocator.Current.GetService <ICursorFactory>();
            StorageProvider = new SystemDialogs(this, _factory.CreateSystemDialogs());
        }
Пример #4
0
        internal WindowImpl(IAvaloniaNativeFactory factory, AvaloniaNativePlatformOptions opts,
                            AvaloniaNativePlatformOpenGlInterface glFeature) : base(opts, glFeature)
        {
            _factory   = factory;
            _opts      = opts;
            _glFeature = glFeature;
            using (var e = new WindowEvents(this))
            {
                var context = _opts.UseGpu ? glFeature?.MainContext : null;
                Init(_native = factory.CreateWindow(e, context?.Context), factory.CreateScreens(), context);
            }

            NativeMenuExporter = new AvaloniaNativeMenuExporter(_native, factory);
        }
Пример #5
0
 public PopupImpl(IAvaloniaNativeFactory factory,
                  AvaloniaNativePlatformOptions opts,
                  AvaloniaNativePlatformOpenGlInterface glFeature,
                  IWindowBaseImpl parent) : base(factory, opts, glFeature)
 {
     _opts      = opts;
     _glFeature = glFeature;
     _parent    = parent;
     using (var e = new PopupEvents(this))
     {
         var context = _opts.UseGpu ? glFeature?.MainContext : null;
         Init(factory.CreatePopup(e, context?.Context), factory.CreateScreens(), context);
     }
     PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(parent, MoveResize));
 }
Пример #6
0
        void DoInitialize(AvaloniaNativePlatformOptions options)
        {
            _options = options;
            _factory.Initialize(new GCHandleDeallocator());
            if (_factory.MacOptions != null)
            {
                var macOpts = AvaloniaLocator.Current.GetService <MacOSPlatformOptions>();

                _factory.MacOptions.SetShowInDock(macOpts?.ShowInDock != false ? 1 : 0);
                _factory.MacOptions.SetDisableDefaultApplicationMenuItems(
                    macOpts?.DisableDefaultApplicationMenuItems == true ? 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 <IRenderLoop>().ToConstant(new RenderLoop())
            .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
            .Bind <ISystemDialogImpl>().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs()))
            .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Meta))
            .Bind <IMountedVolumeInfoProvider>().ToConstant(new MacOSMountedVolumeInfoProvider())
            .Bind <IPlatformDragSource>().ToConstant(new AvaloniaNativeDragSource(_factory));

            if (_options.UseGpu)
            {
                try
                {
                    AvaloniaLocator.CurrentMutable.Bind <IPlatformOpenGlInterface>()
                    .ToConstant(_platformGl = new AvaloniaNativePlatformOpenGlInterface(_factory.ObtainGlDisplay()));
                }
                catch (Exception)
                {
                    // ignored
                }
            }
        }