internal static DesignerView GetDesignerView(DependencyObject visual) { DesignerView designerView = DesignerView.GetDesignerView(visual); while (designerView == null && visual != null) { visual = VisualTreeHelper.GetParent(visual); if (visual != null) { designerView = DesignerView.GetDesignerView(visual); } } return(designerView); }
internal static Transform GetSelectionFrameTransformToParentVisual(ViewItem view, Visual ancestorView) { if (view != (ViewItem)null && (view.LayoutTransform == null || view.LayoutTransform == Transform.Identity)) { Transform toImmediateParent = TransformUtil.GetTransformToImmediateParent(view); Rect selectionFrameBounds = view.SelectionFrameBounds; Vector vector = new Vector(selectionFrameBounds.X, selectionFrameBounds.Y); Matrix matrix = toImmediateParent.Value; matrix.Translate(vector.X, vector.Y); if ((view.VisualParent == (ViewItem)null ? (object)DesignerView.GetDesignerView((DependencyObject)ancestorView) : view.VisualParent.PlatformObject) != ancestorView) { Transform transformToAncestor = TransformUtil.GetParentTransformToAncestor(view, ancestorView); return((Transform) new MatrixTransform(matrix * transformToAncestor.Value)); } } return(TransformUtil.GetTransformToAncestor(view, ancestorView)); }