public abstract Rect GetInitialChildPlacement( UIElement child, Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout, ref AnimationRate animationRate, out object placementArgs, out bool isDone);
public abstract Rect GetNextChildPlacement( UIElement child, TimeSpan currentTime, Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout, AnimationRate animationRate, ref object placementArgs, out bool isDone);
public override Rect GetInitialChildPlacement( UIElement child, Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout, ref AnimationRate animationRate, out object placementArgs, out bool isDone) { isDone = ( animationRate.HasSpeed && animationRate.Speed <= 0 ) || ( animationRate.HasDuration && animationRate.Duration.Ticks == 0 ); if( !isDone ) { Vector startVector = new Vector( currentPlacement.Left + ( currentPlacement.Width / 2 ), currentPlacement.Top + ( currentPlacement.Height / 2 ) ); Vector finalVector = new Vector( targetPlacement.Left + ( targetPlacement.Width / 2 ), targetPlacement.Top + ( targetPlacement.Height / 2 ) ); Vector distanceVector = startVector - finalVector; animationRate = new AnimationRate( animationRate.HasDuration ? animationRate.Duration : TimeSpan.FromMilliseconds( distanceVector.Length / animationRate.Speed ) ); } placementArgs = currentPlacement; return currentPlacement; }
public override Rect GetNextChildPlacement( UIElement child, TimeSpan currentTime, Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout, AnimationRate animationRate, ref object placementArgs, out bool isDone) { Rect result = targetPlacement; isDone = true; if( _equation != null ) { Rect from = ( Rect )placementArgs; TimeSpan duration = animationRate.Duration; isDone = currentTime >= duration; if( !isDone ) { double x = _equation.Evaluate( currentTime, from.Left, targetPlacement.Left, duration ); double y = _equation.Evaluate( currentTime, from.Top, targetPlacement.Top, duration ); double width = Math.Max( 0, _equation.Evaluate( currentTime, from.Width, targetPlacement.Width, duration ) ); double height = Math.Max( 0, _equation.Evaluate( currentTime, from.Height, targetPlacement.Height, duration ) ); result = new Rect( x, y, width, height ); } } return result; }
public override Rect GetNextChildPlacement( UIElement child, TimeSpan currentTime, Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout, AnimationRate animationRate, ref object placementArgs, out bool isDone ) { throw new InvalidOperationException( ErrorMessages.GetMessage( ErrorMessages.DefaultAnimatorCantAnimate ) ); }
internal static UIElement FindAncestorChildOfAnimationPanel( DependencyObject element, out AnimationPanel panel ) { panel = null; if( element == null ) return null; DependencyObject parent = VisualTreeHelper.GetParent( element ); if( parent == null ) return null; if( parent is AnimationPanel || parent is SwitchPanel ) { panel = ( parent is SwitchPanel ) ? ( parent as SwitchPanel )._currentLayoutPanel : parent as AnimationPanel; return element as UIElement; } return AnimationPanel.FindAncestorChildOfAnimationPanel( parent, out panel ); }