private static DraggableMouseInteraction GetMouseInteraction(MouseEventArgs e)
        {
            var uie = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource);

            return(uie?.GetVisualAncestorsAndSelf()
                   .OfType <UIElement>()
                   .Select(u => u.GetService <DraggableMouseInteractionService>())
                   .SkipNull()
                   .SelectMany(s => s._draggableMouseCollection)
                   .Where(d => d.WillHandleEvent(e))
                   .LastMaxElementOrDefault(d => d.HandlerPriority));
        }
예제 #2
0
        private void QueryCloseOnDown(MouseButtonEventArgsInt e)
        {
            var uieSource = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource);
            var inside    = IsInsideClick(uieSource, e);

            if (inside)
            {
                return;
            }

            QueryCloseCore(new MouseButtonEventPopupCloseReason(e.OriginalArgs));
        }
예제 #3
0
        private static void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.Handled && e.ClickCount != 1)
            {
                return;
            }

            var element   = (DependencyObject)sender;
            var uieSource = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource);

            if (uieSource.GetVisualAncestors().TakeWhile(p => !ReferenceEquals(p, element)).Any(GetNonSelectable))
            {
                return;
            }

            var selectionScope = GetSelectionScope(element);

            if (selectionScope == null)
            {
                return;
            }

            selectionScope.SelectedItem = GetSelectTarget(element) ?? element;
        }
예제 #4
0
        private MouseButtonEventInfo GetMouseDownInfo(MouseButtonEventArgsInt e)
        {
            var uie = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource);

            return(new MouseButtonEventInfo(uie, IsInsideClick(uie, e)));
        }