public void BuildStoryboardForElement(Storyboard storyboard, UIElement element) { var continuumElements = new List <UIElement>(); ItemTurnstileHelper.GetContinuumElements(element, XMode, ref continuumElements); foreach (var continuumElement in continuumElements) { continuumElement.RenderTransform = new CompositeTransform(); string storyBoardname = String.Format("ContinuumLeaf{0}Storyboard", Enum.GetName(typeof(ItemTurnstileXMode), XMode)); var childBoard = Transitions.GetStoryboard(storyBoardname); Storyboard.SetTarget(childBoard, continuumElement); storyboard.Children.Add(childBoard); } }
public void BuildStoryboardForElement(Storyboard storyboard, UIElement element) { storyboard.Duration = transitionDuration; List <UIElement> elements = new List <UIElement>(); ItemTurnstileHelper.GetTurnstileElements(element, XMode, ref elements); for (int i = 0; i < elements.Count; i++) { UIElement child = elements[i]; if (child.Projection == null) { child.Projection = new PlaneProjection(); } GeneralTransform childTransform = child.TransformToVisual(element); Point point = childTransform.Transform(new Point(0, 0)); Rect rectangle = childTransform.TransformBounds(new Rect(new Point(0, 0), child.RenderSize)); //Check if the elements Rect intersects with that of the scrollviewer's rectangle.Intersect(new Rect(new Point(0, 0), element.RenderSize)); //if result is Empty then the element is not in view if (rectangle == Rect.Empty) { continue; } else { TimeSpan animationStart = TimeSpan.Zero; TimeSpan animationEnd = TimeSpan.Zero; switch (XMode) { case ItemTurnstileXMode.BackwardIn: case ItemTurnstileXMode.ForwardIn: animationEnd = GetAnimationStart(element, elements[i], point.Y, point.X); animationStart = animationEnd.Subtract(individualTransitionDuration) < TimeSpan.Zero ? TimeSpan.Zero : animationEnd.Subtract(individualTransitionDuration); break; case ItemTurnstileXMode.BackwardOut: case ItemTurnstileXMode.ForwardOut: animationStart = GetAnimationStart(element, elements[i], point.Y, point.X); animationEnd = animationStart.Add(individualTransitionDuration); break; } var rotationY = GetRotationY(animationStart, animationEnd); Storyboard.SetTarget(rotationY, child); storyboard.Children.Add(rotationY); var rotationZ = GetRotationZ(animationStart, animationEnd); Storyboard.SetTarget(rotationZ, child); storyboard.Children.Add(rotationZ); var fade = GetFade(animationStart, animationEnd); Storyboard.SetTarget(fade, child); storyboard.Children.Add(fade); var centerX = GetCenterX(child, point); Storyboard.SetTarget(centerX, child); storyboard.Children.Add(centerX); } } }