public static IDisposable Attach(TopLevel control) { return(control.AddHandler( KeyDownEvent, WindowPreviewKeyDown, RoutingStrategies.Tunnel)); }
/// <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); }
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); }
/// <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); }
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); }
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)); }
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)); }
/// <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); }