示例#1
0
        private static void ProcessSources()
        {
            if (IsAutoActivationEnabled == false)
            {
                return;
            }

            var theme = ApplicationThemeCore;

            foreach (var source in PresentationTreeUtils.EnumerateVisualRoots())
            {
                var freSource = source as FrameworkElement;

                if (freSource == null)
                {
                    continue;
                }

                var parent = freSource.Parent;

                var themeTarget = parent is Popup || parent is Window ? parent : freSource;

                EnsureTheme(themeTarget, theme);
            }

            foreach (var enumeratePopup in PresentationTreeUtils.EnumeratePopups())
            {
                EnsureTheme(enumeratePopup, theme);
            }
        }
示例#2
0
 private static void CompositionTargetOnRendering(object sender, EventArgs eventArgs)
 {
     foreach (var visualRoot in PresentationTreeUtils.EnumerateVisualRoots().OfType <UIElement>())
     {
         EnsureService(visualRoot);
     }
 }
        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));
        }
示例#4
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));
        }
示例#5
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;
        }
示例#6
0
 public static IEnumerable <DependencyObject> GetVisualAncestorsAndSelf(this DependencyObject depObj)
 {
     return(PresentationTreeUtils.GetVisualAncestors(depObj, true));
 }
示例#7
0
 public static T GetLogicalParent <T>(this DependencyObject depObj) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetLogicalParent(depObj) as T);
 }
示例#8
0
 public static DependencyObject GetLogicalParent(this DependencyObject depObj)
 {
     return(PresentationTreeUtils.GetLogicalParent(depObj));
 }
示例#9
0
 public static IEnumerable <DependencyObject> GetLogicalAncestors(this DependencyObject depObj)
 {
     return(PresentationTreeUtils.GetLogicalAncestors(depObj, false));
 }
示例#10
0
 public static IEnumerable <T> GetLogicalAncestors <T>(this DependencyObject depObj) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetLogicalAncestors(depObj, false).OfType <T>());
 }
示例#11
0
        private MouseButtonEventInfo GetMouseDownInfo(MouseButtonEventArgsInt e)
        {
            var uie = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource);

            return(new MouseButtonEventInfo(uie, IsInsideClick(uie, e)));
        }
示例#12
0
 public static bool IsKeyboardFocusWithin(DependencyObject dependencyObject)
 {
     return(GetKeyboardFocusedElement() is DependencyObject keyboardFocusedElement && PresentationTreeUtils.IsWithinTree(dependencyObject, keyboardFocusedElement));
 }
示例#13
0
 internal static bool IsInLiveTree(this FrameworkElement fre)
 {
     return(PresentationTreeUtils.EnumerateVisualRoots().Where(e => e.Dispatcher.CheckAccess()).Any(vr => ReferenceEquals(vr, fre) || vr?.IsVisualAncestorOf(fre) == true));
 }
示例#14
0
 public static DependencyObject GetParent(this DependencyObject depObj, TreeEnumerationStrategy strategy)
 {
     return(PresentationTreeUtils.GetParent(depObj, strategy));
 }
示例#15
0
 public static IEnumerable <DependencyObject> GetVisualDescendantsAndSelf(this DependencyObject parent, Func <DependencyObject, bool> excludeSubtree)
 {
     return(PresentationTreeUtils.GetVisualDescendants(parent, true, excludeSubtree));
 }
示例#16
0
 public static IEnumerable <T> GetVisualDescendantsAndSelf <T>(this DependencyObject parent) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetVisualDescendants(parent, true, null).OfType <T>());
 }
示例#17
0
 public static IEnumerable <DependencyObject> GetVisualDescendantsAndSelf(this DependencyObject parent)
 {
     return(PresentationTreeUtils.GetVisualDescendants(parent, true, null));
 }
示例#18
0
 public static IEnumerable <T> GetVisualChildrenAndSelf <T>(this DependencyObject parent) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetVisualChildren(parent, true).OfType <T>());
 }
示例#19
0
 public static IEnumerable <T> GetVisualAncestorsAndSelf <T>(this DependencyObject depObj) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetVisualAncestors(depObj, true).OfType <T>());
 }
示例#20
0
 public static IEnumerable <DependencyObject> GetVisualChildren(this DependencyObject parent)
 {
     return(PresentationTreeUtils.GetVisualChildren(parent, false));
 }
示例#21
0
 public static IEnumerable <DependencyObject> GetAncestorsAndSelf(this DependencyObject depObj, TreeEnumerationStrategy strategy)
 {
     return(PresentationTreeUtils.GetAncestors(depObj, true, strategy));
 }
示例#22
0
 public static T GetParent <T>(this DependencyObject depObj, TreeEnumerationStrategy strategy) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetParent(depObj, strategy) as T);
 }
示例#23
0
 public static IEnumerable <T> GetAncestorsAndSelf <T>(this DependencyObject depObj, TreeEnumerationStrategy strategy) where T : DependencyObject
 {
     return(PresentationTreeUtils.GetAncestors(depObj, true, strategy).OfType <T>());
 }