internal static MatrixTransform GetAnimationTransform(FrameworkElement element) { Matrix matrix1 = new Matrix(); Transform thisObject1 = element.TransformToVisual((Visual)Window.GetWindow((DependencyObject)element)) as Transform; if (thisObject1 != null) { matrix1 = MatrixHelper.Multiply(matrix1, TransformExtensions.GetMatrix(thisObject1)); } Transform thisObject2 = FrameworkElementExtensions.RenderTransformToAncestor(element, (DependencyObject)null).Inverse as Transform; if (thisObject2 != null) { matrix1 = MatrixHelper.Multiply(matrix1, TransformExtensions.GetMatrix(thisObject2)); } return(new MatrixTransform() { Matrix = matrix1 }); }
private static Transform TransformToAncestorHelper(FrameworkElement element, DependencyObject parent, DependencyProperty property) { Matrix matrix = Matrix.Identity; foreach (DependencyObject dependencyObject in VisualTreeExtensions.GetVisualAncestorsAndSelf((DependencyObject)element)) { if (dependencyObject != parent) { Transform thisObject = (Transform)dependencyObject.GetValue(property); if (thisObject != null) { matrix = MatrixHelper.Multiply(matrix, TransformExtensions.GetMatrix(thisObject)); } } else { break; } } return((Transform)TransformExtensions.MakeMatrixTransform(matrix)); }