示例#1
0
        public virtual void Detach(IMenu menu)
        {
            if (Menu != menu)
            {
                throw new NotSupportedException("DefaultMenuInteractionHandler is not attached to the menu.");
            }

            Menu.GotFocus        -= GotFocus;
            Menu.LostFocus       -= LostFocus;
            Menu.KeyDown         -= KeyDown;
            Menu.PointerPressed  -= PointerPressed;
            Menu.PointerReleased -= PointerReleased;
            Menu.RemoveHandler(AccessKeyHandler.AccessKeyPressedEvent, AccessKeyPressed);
            Menu.RemoveHandler(Avalonia.Controls.Menu.MenuOpenedEvent, this.MenuOpened);
            Menu.RemoveHandler(MenuItem.PointerEnterItemEvent, PointerEnter);
            Menu.RemoveHandler(MenuItem.PointerLeaveItemEvent, PointerLeave);

            if (_root is InputElement inputRoot)
            {
                inputRoot.RemoveHandler(InputElement.PointerPressedEvent, RootPointerPressed);
            }

            if (_root is WindowBase root)
            {
                root.Deactivated -= WindowDeactivated;
            }

            _inputManagerSubscription?.Dispose();

            Menu  = null;
            _root = null;
        }
示例#2
0
        public virtual void Attach(IMenu menu)
        {
            if (Menu != null)
            {
                throw new NotSupportedException("DefaultMenuInteractionHandler is already attached.");
            }

            Menu                  = menu;
            Menu.GotFocus        += GotFocus;
            Menu.LostFocus       += LostFocus;
            Menu.KeyDown         += KeyDown;
            Menu.PointerPressed  += PointerPressed;
            Menu.PointerReleased += PointerReleased;
            Menu.AddHandler(AccessKeyHandler.AccessKeyPressedEvent, AccessKeyPressed);
            Menu.AddHandler(Avalonia.Controls.Menu.MenuOpenedEvent, this.MenuOpened);
            Menu.AddHandler(MenuItem.PointerEnterItemEvent, PointerEnter);
            Menu.AddHandler(MenuItem.PointerLeaveItemEvent, PointerLeave);

            _root = Menu.VisualRoot;

            if (_root is InputElement inputRoot)
            {
                inputRoot.AddHandler(InputElement.PointerPressedEvent, RootPointerPressed, RoutingStrategies.Tunnel);
            }

            if (_root is WindowBase window)
            {
                window.Deactivated += WindowDeactivated;
            }

            _inputManagerSubscription = InputManager?.Process.Subscribe(RawInput);
        }
 public static RadioButtonGroupManager GetOrCreateForRoot(IRenderRoot?root)
 {
     if (root == null)
     {
         return(Default);
     }
     return(s_registeredVisualRoots.GetValue(root, key => new RadioButtonGroupManager()));
 }
示例#4
0
        public virtual void Detach(IMenu menu)
        {
            if (Menu != menu)
            {
                throw new NotSupportedException("DefaultMenuInteractionHandler is not attached to the menu.");
            }

            Menu.GotFocus        -= GotFocus;
            Menu.LostFocus       -= LostFocus;
            Menu.KeyDown         -= KeyDown;
            Menu.PointerPressed  -= PointerPressed;
            Menu.PointerReleased -= PointerReleased;
            Menu.RemoveHandler(AccessKeyHandler.AccessKeyPressedEvent, AccessKeyPressed);
            Menu.RemoveHandler(MenuBase.MenuOpenedEvent, MenuOpened);
            Menu.RemoveHandler(MenuItem.PointerEnteredItemEvent, PointerEntered);
            Menu.RemoveHandler(MenuItem.PointerExitedItemEvent, PointerExited);
            Menu.RemoveHandler(InputElement.PointerMovedEvent, PointerMoved);

            if (_root is InputElement inputRoot)
            {
                inputRoot.RemoveHandler(InputElement.PointerPressedEvent, RootPointerPressed);
            }

            if (_root is WindowBase root)
            {
                root.Deactivated -= WindowDeactivated;
            }

            if (_root is TopLevel tl && tl.PlatformImpl != null)
            {
                tl.PlatformImpl.LostFocus -= TopLevelLostPlatformFocus;
            }

            _inputManagerSubscription?.Dispose();

            Menu  = null;
            _root = null;
        }
示例#5
0
        public virtual void Attach(IMenu menu)
        {
            if (Menu != null)
            {
                throw new NotSupportedException("DefaultMenuInteractionHandler is already attached.");
            }

            Menu                  = menu;
            Menu.GotFocus        += GotFocus;
            Menu.LostFocus       += LostFocus;
            Menu.KeyDown         += KeyDown;
            Menu.PointerPressed  += PointerPressed;
            Menu.PointerReleased += PointerReleased;
            Menu.AddHandler(AccessKeyHandler.AccessKeyPressedEvent, AccessKeyPressed);
            Menu.AddHandler(MenuBase.MenuOpenedEvent, MenuOpened);
            Menu.AddHandler(MenuItem.PointerEnteredItemEvent, PointerEntered);
            Menu.AddHandler(MenuItem.PointerExitedItemEvent, PointerExited);
            Menu.AddHandler(InputElement.PointerMovedEvent, PointerMoved);

            _root = Menu.VisualRoot;

            if (_root is InputElement inputRoot)
            {
                inputRoot.AddHandler(InputElement.PointerPressedEvent, RootPointerPressed, RoutingStrategies.Tunnel);
            }

            if (_root is WindowBase window)
            {
                window.Deactivated += WindowDeactivated;
            }

            if (_root is TopLevel tl && tl.PlatformImpl is ITopLevelImpl pimpl)
            {
                pimpl.LostFocus += TopLevelLostPlatformFocus;
            }

            _inputManagerSubscription = InputManager?.Process.Subscribe(RawInput);
        }
示例#6
0
 private ImmediateRenderer(IVisual root, bool updateTransformedBounds)
 {
     _root = root ?? throw new ArgumentNullException(nameof(root));
     _renderRoot = root as IRenderRoot;
     _updateTransformedBounds = updateTransformedBounds;
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmediateRenderer"/> class.
 /// </summary>
 /// <param name="root">The control to render.</param>
 public ImmediateRenderer(IVisual root)
 {
     _root = root ?? throw new ArgumentNullException(nameof(root));
     _renderRoot = root as IRenderRoot;
 }