Exemplo n.º 1
0
        internal static bool IsAncestorOf(DependencyObject reference, DependencyObject descendant)
        {
            Visual   visual;
            Visual3D visual3D;

            VisualTreeUtils.AsNonNullVisual(reference, out visual, out visual3D);

            // x86 branch prediction skips the branch on first encounter.  We favor 2D.
            if (visual3D != null)
            {
                return(visual3D.IsAncestorOf(descendant));
            }

            return(visual.IsAncestorOf(descendant));
        }
Exemplo n.º 2
0
        internal static DependencyObject FindCommonAncestor(DependencyObject reference, DependencyObject otherVisual)
        {
            Visual   visual;
            Visual3D visual3D;

            VisualTreeUtils.AsNonNullVisual(reference, out visual, out visual3D);

            // x86 branch prediction skips the branch on first encounter.  We favor 2D.
            if (visual3D != null)
            {
                return(visual3D.FindCommonVisualAncestor(otherVisual));
            }

            return(visual.FindCommonVisualAncestor(otherVisual));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Visual parent of this Visual.
        /// </summary>
        public static DependencyObject GetParent(DependencyObject reference)
        {
            Visual   visual;
            Visual3D visual3D;

            VisualTreeUtils.AsNonNullVisual(reference, out visual, out visual3D);

            // x86 branch prediction skips the branch on first encounter.  We favor 2D.
            if (visual3D != null)
            {
                return(visual3D.InternalVisualParent);
            }

            return(visual.InternalVisualParent);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the child of Visual visual at the specified index.
        /// </summary>
        public static DependencyObject GetChild(DependencyObject reference, int childIndex)
        {
            Visual   visual;
            Visual3D visual3D;

            VisualTreeUtils.AsNonNullVisual(reference, out visual, out visual3D);

            // x86 branch prediction skips the branch on first encounter.  We favor 2D.
            if (visual3D != null)
            {
                return(visual3D.InternalGet2DOr3DVisualChild(childIndex));
            }

            //
            // Even though visual is a 2D visual, it still may have
            // 3D children.
            //
            return(visual.InternalGet2DOr3DVisualChild(childIndex));
        }