public static Rect GetSelectionFrameBounds(DependencyObject element) { FrameworkElement element1 = element as FrameworkElement; if (element1 != null && (element1.LayoutTransform == null || element1.LayoutTransform == Transform.Identity)) { return(ElementUtilities.GetActualBoundsInParent(element1)); } return(ElementUtilities.GetRenderSizeBounds(element)); }
public static Rect GetElementRelativeSelectionFrameBounds(DependencyObject element) { FrameworkElement element1 = element as FrameworkElement; if (element1 != null) { return(ElementUtilities.GetActualBoundsCore(element1, false)); } Rect renderSizeBounds = ElementUtilities.GetRenderSizeBounds(element); renderSizeBounds.Location = new Point(); return(renderSizeBounds); }
public static Rect GetLayoutRect(DependencyObject element) { FrameworkElement element1 = element as FrameworkElement; if (element1 != null) { return(LayoutInformation.GetLayoutSlot(element1)); } Rect renderSizeBounds = ElementUtilities.GetRenderSizeBounds(element); renderSizeBounds.Location = new Point(); return(renderSizeBounds); }
public static FrameworkElement FindElementInVisualTree(Visual root, string id) { FrameworkElement frameworkElement = root as FrameworkElement; if (frameworkElement != null && frameworkElement.Name == id) { return(frameworkElement); } for (int childIndex = 0; childIndex < VisualTreeHelper.GetChildrenCount((DependencyObject)root); ++childIndex) { Visual root1 = VisualTreeHelper.GetChild((DependencyObject)root, childIndex) as Visual; if (root1 != null) { FrameworkElement elementInVisualTree = ElementUtilities.FindElementInVisualTree(root1, id); if (elementInVisualTree != null) { return(elementInVisualTree); } } } return((FrameworkElement)null); }
public static Rect GetTransformedBounds(Visual visual, Visual ancestor) { FrameworkElement element = visual as FrameworkElement; Rect rect = new Rect(); if (element != null) { rect = ElementUtilities.GetActualBoundsCore(element, false); } else { UIElement uiElement = visual as UIElement; if (uiElement != null) { rect.Size = uiElement.RenderSize; } else { rect = VisualTreeHelper.GetContentBounds(visual); } } return(TransformUtil.GetTransformToAncestor((DependencyObject)visual, ancestor).TransformBounds(rect)); }
public static bool HasAncestorOfTypeInVisualTree(ViewItem rootElement, ViewItem element, Type type) { return(ElementUtilities.GetAncestorOfTypeInVisualTree(rootElement, element, type) != (ViewItem)null); }
public static bool HasAncestorOfType(FrameworkElement rootElement, FrameworkElement element, Type type) { return(ElementUtilities.GetAncestorOfType(rootElement, element, type) != null); }
public static Rect GetRenderSizeBounds(DependencyObject element) { if (element == null) { throw new ArgumentNullException("element"); } Rect rect = new Rect(); Visual visual = element as Visual; if (visual == null) { return(rect); } rect.Location = (Point)VisualTreeHelper.GetOffset(visual); UIElement uiElement = visual as UIElement; if (uiElement == null) { Size size = VisualTreeHelper.GetContentBounds(visual).Size; if (size.Width <= 0.0 && size.Height <= 0.0) { Visual parentVisual = VisualTreeHelper.GetParent((DependencyObject)visual) as Visual; if (parentVisual != null) { size = TransformUtil.GetTransformToDescendant(parentVisual, visual).TransformBounds(ElementUtilities.GetSelectionFrameBounds((DependencyObject)parentVisual)).Size; } } rect.Size = size; } else { rect.Size = uiElement.RenderSize; } return(rect); }
private static Rect GetActualBoundsInParent(FrameworkElement element) { return(ElementUtilities.GetActualBoundsCore(element, true)); }
public static Rect GetActualBounds(FrameworkElement element) { return(ElementUtilities.GetActualBoundsCore(element, false)); }