private double CalculateYOffset(FrameworkElement itemToAnimate) { FrameworkElement rootElement = this.containerToAnimate; // TODO - get the root Point globalCoords = ElementTreeHelper.SafeTransformPoint(itemToAnimate, rootElement, new Point()); double heightAdjustment = itemToAnimate.ActualHeight / 2; double yCoord = globalCoords.Y + heightAdjustment; return((rootElement.ActualHeight / 2) - yCoord); }
private bool IsItemVisible(FrameworkElement itemToAdd) { if (itemToAdd == null || itemToAdd.Visibility == Visibility.Collapsed) { return(false); } Size renderSize = itemToAdd.RenderSize; if (renderSize.Width == 0 || renderSize.Height == 0) { return(false); } FrameworkElement rootVisual = Window.Current.Content as FrameworkElement; Point globalPosition = ElementTreeHelper.SafeTransformPoint(itemToAdd, rootVisual, new Point()); double itemWidth = itemToAdd.Width; double itemHeight = itemToAdd.Height; if ((globalPosition.X + itemWidth) < 0 || (globalPosition.Y + itemHeight) < 0 || globalPosition.X > rootVisual.ActualWidth || globalPosition.Y > rootVisual.ActualHeight) { return(false); } ScrollViewer parentScrollViewer = ElementTreeHelper.FindVisualAncestor <ScrollViewer>(itemToAdd); if (parentScrollViewer != null) { Point localPosition = ElementTreeHelper.SafeTransformPoint(itemToAdd, parentScrollViewer, new Point()); if ((localPosition.X + itemWidth) < 0 || (localPosition.Y + itemHeight) < 0 || localPosition.X > parentScrollViewer.ActualWidth || localPosition.Y > parentScrollViewer.ActualHeight) { return(false); } } return(true); }
/// <summary> /// Core update routine. /// </summary> /// <param name="context">The context that holds information about the animation.</param> protected override void UpdateAnimationOverride(AnimationContext context) { if (context == null) { return; } this.continuumElement = RadContinuumAnimation.GetContinuumElement(context.Target); if (this.continuumElement == null) { return; } if (!(this.continuumElement is TextBlock)) { TextBlock textBlock = ElementTreeHelper.FindVisualDescendant <TextBlock>(this.continuumElement); if (textBlock != null) { this.continuumElement = textBlock; } } /////context.Storyboard.Duration = new Duration(TimeSpan.FromMilliseconds(500)); this.headerElement = RadContinuumAnimation.GetHeaderElement(context.Target); if (this.headerElement != null) { this.headerElementScreenShotInfo = new ElementScreenShotInfo(this.headerElement); this.headerElementScreenShotInfo.Popup.IsOpen = true; } this.continuumElementScreenShotInfo = new ElementScreenShotInfo(this.continuumElement); this.continuumElementScreenShotInfo.Popup.IsOpen = true; this.ApplyPageAnimation(); this.ApplyContinuumElementAnimation(); if (this.headerElement != null) { this.ApplyPageHeaderAnimation(); } base.UpdateAnimationOverride(context); }