Ejemplo n.º 1
0
 public static IDisposable Attach(TopLevel control)
 {
     return(control.AddHandler(
                KeyDownEvent,
                WindowPreviewKeyDown,
                RoutingStrategies.Tunnel));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens the popup.
        /// </summary>
        public void Open()
        {
            if (_popupRoot == null)
            {
                _popupRoot = new PopupRoot(DependencyResolver)
                {
                    [~ContentControl.ContentProperty] = this[~ChildProperty],
                    [~WidthProperty]     = this[~WidthProperty],
                    [~HeightProperty]    = this[~HeightProperty],
                    [~MinWidthProperty]  = this[~MinWidthProperty],
                    [~MaxWidthProperty]  = this[~MaxWidthProperty],
                    [~MinHeightProperty] = this[~MinHeightProperty],
                    [~MaxHeightProperty] = this[~MaxHeightProperty],
                };

                ((ISetLogicalParent)_popupRoot).SetParent(this);
            }

            _popupRoot.SetPosition(GetPosition());
            _popupRoot.AddHandler(PointerPressedEvent, MaybeClose, RoutingStrategies.Bubble, true);

            if (_topLevel != null)
            {
                _topLevel.Deactivated += MaybeClose;
                _topLevel.AddHandler(PointerPressedEvent, MaybeClose, RoutingStrategies.Tunnel);
            }

            PopupRootCreated?.Invoke(this, EventArgs.Empty);

            _popupRoot.Show();
            IsOpen = true;
            Opened?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 3
0
 public static void AttachScreenshot(this TopLevel root, KeyGesture gesture)
 {
     root.AddHandler(InputElement.KeyDownEvent, async(sender, args) =>
     {
         if (args.Key == Key.F6)
         {
             await Save(root);
         }
     }, RoutingStrategies.Tunnel);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Opens the popup.
        /// </summary>
        public void Open()
        {
            if (_popupRoot == null)
            {
                _popupRoot = new PopupRoot(DependencyResolver)
                {
                    [~ContentControl.ContentProperty] = this[~ChildProperty],
                    [~WidthProperty]     = this[~WidthProperty],
                    [~HeightProperty]    = this[~HeightProperty],
                    [~MinWidthProperty]  = this[~MinWidthProperty],
                    [~MaxWidthProperty]  = this[~MaxWidthProperty],
                    [~MinHeightProperty] = this[~MinHeightProperty],
                    [~MaxHeightProperty] = this[~MaxHeightProperty],
                };

                ((ISetLogicalParent)_popupRoot).SetParent(this);
            }

            _popupRoot.Position = GetPosition();

            if (_topLevel == null && PlacementTarget != null)
            {
                _topLevel = PlacementTarget.GetSelfAndLogicalAncestors().First(x => x is TopLevel) as TopLevel;
            }

            if (_topLevel != null)
            {
                var window = _topLevel as Window;
                if (window != null)
                {
                    window.Deactivated += WindowDeactivated;
                }
                else
                {
                    var parentPopuproot = _topLevel as PopupRoot;
                    if (parentPopuproot != null && parentPopuproot.Parent != null)
                    {
                        ((Popup)(parentPopuproot.Parent)).Closed += ParentClosed;
                    }
                }
                _topLevel.AddHandler(PointerPressedEvent, PointerPressedOutside, RoutingStrategies.Tunnel);
                _nonClientListener = InputManager.Instance.Process.Subscribe(ListenForNonClientClick);
            }

            PopupRootCreated?.Invoke(this, EventArgs.Empty);

            _popupRoot.Show();

            _ignoreIsOpenChanged = true;
            IsOpen = true;
            _ignoreIsOpenChanged = false;

            Opened?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 5
0
    public static void AttachCapture(this TopLevel root, KeyGesture gesture)
    {
        async void Handler(object?sender, KeyEventArgs args)
        {
            if (args.Key == Key.F6)
            {
                await Save(root);
            }
        }

        root.AddHandler(InputElement.KeyDownEvent, Handler, RoutingStrategies.Tunnel);
    }
Ejemplo n.º 6
0
        public static IDisposable Attach(TopLevel control, KeyGesture gesture)
        {
            void PreviewKeyDown(object sender, KeyEventArgs e)
            {
                if (gesture.Matches(e))
                {
                    OpenDevTools(control);
                }
            }

            return(control.AddHandler(
                       KeyDownEvent,
                       PreviewKeyDown,
                       RoutingStrategies.Tunnel));
        }
Ejemplo n.º 7
0
        public static IDisposable Attach(TopLevel root, KeyGesture gesture)
        {
            void PreviewKeyDown(object sender, KeyEventArgs e)
            {
                if (gesture.Matches(e))
                {
                    Open(root);
                }
            }

            return(root.AddHandler(
                       InputElement.KeyDownEvent,
                       PreviewKeyDown,
                       RoutingStrategies.Tunnel));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Opens the popup.
        /// </summary>
        public void Open()
        {
            if (_popupRoot == null)
            {
                _popupRoot = new PopupRoot(DependencyResolver)
                {
                    [~ContentControl.ContentProperty] = this[~ChildProperty],
                    [~WidthProperty]     = this[~WidthProperty],
                    [~HeightProperty]    = this[~HeightProperty],
                    [~MinWidthProperty]  = this[~MinWidthProperty],
                    [~MaxWidthProperty]  = this[~MaxWidthProperty],
                    [~MinHeightProperty] = this[~MinHeightProperty],
                    [~MaxHeightProperty] = this[~MaxHeightProperty],
                };

                ((ISetLogicalParent)_popupRoot).SetParent(this);
            }

            _popupRoot.Position = GetPosition();

            if (_topLevel == null && PlacementTarget != null)
            {
                _topLevel = PlacementTarget.GetSelfAndLogicalAncestors().First(x => x is TopLevel) as TopLevel;
            }

            if (_topLevel != null)
            {
                _topLevel.Deactivated += TopLevelDeactivated;
                _topLevel.AddHandler(PointerPressedEvent, PointerPressedOutside, RoutingStrategies.Tunnel);
            }

            PopupRootCreated?.Invoke(this, EventArgs.Empty);

            _popupRoot.Show();
            IsOpen = true;
            Opened?.Invoke(this, EventArgs.Empty);
        }