Beispiel #1
0
        protected override Storyboard CreateStoryboardForNewPresenter(ITransitionContainer container)
        {
            var zeroKeyTime   = KeyTime.FromTimeSpan(TimeSpan.Zero);
            var midishKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));
            var endKeyTime    = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));

            var slideAnimation = new DoubleAnimationUsingKeyFrames();

            slideAnimation.KeyFrames.Add(new LinearDoubleKeyFrame(container.ActualHeight, zeroKeyTime));
            slideAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(container.ActualHeight, midishKeyTime)
            {
                EasingFunction = _sineEase
            });
            slideAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime)
            {
                EasingFunction = _sineEase
            });

            Storyboard storyboard = new Storyboard();

            storyboard.Children.Add(slideAnimation);
            Storyboard.SetTargetProperty(slideAnimation, new PropertyPath(TranslateTransform.YProperty));

            return(storyboard);
        }
Beispiel #2
0
        protected override Storyboard CreateStoryboardForOldPresenter(ITransitionContainer container)
        {
            var zeroKeyTime   = KeyTime.FromTimeSpan(TimeSpan.Zero);
            var midishKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));
            var endKeyTime    = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));

            var scaleAnimation = new DoubleAnimationUsingKeyFrames();

            scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
            scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(.8, endKeyTime));

            var opacityAnimation = new DoubleAnimationUsingKeyFrames();

            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime));

            Storyboard storyboard = new Storyboard();

            storyboard.Children.Add(scaleAnimation);
            Storyboard.SetTargetProperty(scaleAnimation, new PropertyPath(ScaleTransform.ScaleXProperty));
            Storyboard.SetTargetProperty(scaleAnimation, new PropertyPath(ScaleTransform.ScaleYProperty));
            storyboard.Children.Add(opacityAnimation);
            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(UIElement.OpacityProperty));

            return(storyboard);
        }
Beispiel #3
0
        protected override Storyboard CreateStoryboardForNewPresenter(ITransitionContainer container)
        {
            double toStartX = 0, toEndX = 0;
            double toStartY = 0, toEndY = 0;

            switch (Direction)
            {
            case SlideDirection.Left:
                toStartX = container.ActualWidth;
                break;

            case SlideDirection.Right:
                toStartX = -container.ActualWidth;
                break;

            case SlideDirection.Up:
                toStartY = container.ActualHeight;
                break;

            case SlideDirection.Down:
                toStartY = -container.ActualHeight;
                break;

            default:
                break;
            }

            return(GetStoryboard(toStartX, toEndX, toStartY, toEndY));
        }
Beispiel #4
0
        protected override Storyboard CreateStoryboardForOldPresenter(ITransitionContainer container)
        {
            double fromStartX = 0, fromEndX = 0;
            double fromStartY = 0, fromEndY = 0;

            switch (Direction)
            {
            case SlideDirection.Left:
                fromEndX = -container.ActualWidth - 1;
                break;

            case SlideDirection.Right:
                fromEndX = container.ActualWidth + 1;
                break;

            case SlideDirection.Up:
                fromEndY = -container.ActualHeight - 1;
                break;

            case SlideDirection.Down:
                fromEndY = container.ActualHeight + 1;
                break;

            default:
                break;
            }

            return(GetStoryboard(fromStartX, fromEndX, fromStartY, fromEndY));
        }
Beispiel #5
0
 public Transition(ITransitionContainer container, IAMTimelineObj timelineObj, string name, double offset,
                   double duration, bool swapInputs,
                   TransitionDefinition transitionDefinition)
 {
     _container = container;
     _timelineObj = timelineObj;
     _name = name;
     _offset = offset;
     _duration = duration;
     _swapInputs = swapInputs;
     _transitionDefinition = transitionDefinition;
 }
 public Transition(ITransitionContainer container, IAMTimelineObj timelineObj, string name, double offset,
                   double duration, bool swapInputs,
                   TransitionDefinition transitionDefinition)
 {
     _container            = container;
     _timelineObj          = timelineObj;
     _name                 = name;
     _offset               = offset;
     _duration             = duration;
     _swapInputs           = swapInputs;
     _transitionDefinition = transitionDefinition;
 }
Beispiel #7
0
        protected override Storyboard CreateStoryboardForNewPresenter(ITransitionContainer container)
        {
            var zeroKeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero);
            var endKeyTime  = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5));

            var toAnimation = new DoubleAnimationUsingKeyFrames();

            toAnimation.KeyFrames.Add(new LinearDoubleKeyFrame(0, zeroKeyTime));
            toAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, endKeyTime, _sineEase));

            var storyboard = new Storyboard();

            storyboard.Duration = TimeSpan.FromSeconds(1);
            storyboard.Children.Add(toAnimation);
            Storyboard.SetTargetProperty(toAnimation, new PropertyPath(UIElement.OpacityProperty));

            return(storyboard);
        }
Beispiel #8
0
        /// <summary>
        /// Creates a des transition, wraps it into an ITransition, adds it to a collection
        /// and returns a new ITransition wrapper.
        /// </summary>
        /// <param name="desTimeline"></param>
        /// <param name="transable"></param>
        /// <param name="transitions"></param>
        /// <param name="name"></param>
        /// <param name="offset"></param>
        /// <param name="duration"></param>
        /// <param name="transitionDefinition"></param>
        /// <param name="swapInputs"></param>
        /// <returns></returns>
        internal static ITransition AddTransitionToCollection(ITransitionContainer container, IAMTimeline desTimeline,
                                                              IAMTimelineTransable transable,
                                                              AddOnlyList <ITransition> transitions, string name,
                                                              double offset, double duration,
                                                              TransitionDefinition transitionDefinition, bool swapInputs)
        {
            CheckForTransitionOveralp(container, offset, duration);

            IAMTimelineObj desTransition =
                InsertTransition(desTimeline, transable, name, offset, duration, transitionDefinition, swapInputs);

            ITransition transition =
                new Transition(container, desTransition, name, offset, duration, swapInputs, transitionDefinition);

            transitions.Add(transition);

            return(transition);
        }
Beispiel #9
0
        private static void CheckForTransitionOveralp(ITransitionContainer container, double offset, double duratinon)
        {
            double prospectStart = offset;
            double prospectEnd   = duratinon + offset;

            for (int i = 0; i < container.Transitions.Count; i++)
            {
                ITransition transition = container.Transitions[i];
                double      start      = transition.Offset;
                double      end        = transition.Offset + transition.Duration;

                if ((prospectStart < end) && (prospectEnd > start))
                {
                    throw new SplicerException(
                              string.Format("Propsective transition overlaps with an existing transition at index: {0}", i));
                }
            }
        }
Beispiel #10
0
 protected override Storyboard PrepareStoryboardForNewPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     newPresenter.Opacity = 0;
     return(base.PrepareStoryboardForNewPresenter(oldPresenter, newPresenter, origin, container));
 }
Beispiel #11
0
        public virtual void Wipe(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
        {
            switch (OriginZIndexOrder)
            {
            case ZIndexOrder.NewPresenterAbove:
                container.SetZIndexOrderBy(newPresenter, oldPresenter);
                break;

            case ZIndexOrder.OldPresenterAbove:
                container.SetZIndexOrderBy(oldPresenter, newPresenter);
                break;

            default:
                break;
            }
            if (oldPresenter == null && newPresenter == null)
            {
                OnCompletedTransition(null, null, null, null, origin, container);
                return;
            }
            var oldStoryboard = PrepareStoryboardForOldPresenter(oldPresenter, newPresenter, origin, container);
            var newStoryboard = PrepareStoryboardForNewPresenter(oldPresenter, newPresenter, origin, container);

            if (oldStoryboard == null && newStoryboard == null)
            {
                OnCompletedTransition(null, oldPresenter, null, newPresenter, origin, container);
                return;
            }
            oldPresenter.Visibility = Visibility.Visible;
            newPresenter.Visibility = Visibility.Visible;
            var order = this.TransitionOrder;

            switch (order)
            {
            case TransitionOrder.Both:
                int complatedCount = 0, transitionCount = 0;
                if (oldStoryboard != null && oldPresenter != null)
                {
                    transitionCount++;
                    this.BeginTransition(oldStoryboard, oldPresenter, container, (s, e) =>
                    {
                        complatedCount++;
                        OnEndedTransitionOfOldPresenter(oldPresenter, newPresenter, origin, container);
                        if (complatedCount >= transitionCount)
                        {
                            OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                        }
                    });
                }
                if (newStoryboard != null && newPresenter != null)
                {
                    transitionCount++;
                    this.BeginTransition(newStoryboard, newPresenter, container, (s, e) =>
                    {
                        complatedCount++;
                        OnEndedTransitionOfNewPresenter(oldPresenter, newPresenter, origin, container);
                        if (complatedCount >= transitionCount)
                        {
                            OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                        }
                    });
                }
                break;

            case TransitionOrder.OldFirst:
                if (oldStoryboard != null && oldPresenter != null)
                {
                    this.BeginTransition(oldStoryboard, oldPresenter, container, (s, e) =>
                    {
                        OnEndedTransitionOfOldPresenter(oldPresenter, newPresenter, origin, container);
                        if (newStoryboard != null && newPresenter != null)
                        {
                            this.BeginTransition(newStoryboard, newPresenter, container, (s1, e1) =>
                            {
                                OnEndedTransitionOfNewPresenter(oldPresenter, newPresenter, origin, container);
                                OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                            });
                        }
                        else
                        {
                            OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                        }
                    });
                }
                else if (newStoryboard != null && newPresenter != null)
                {
                    this.BeginTransition(newStoryboard, newPresenter, container, (s, e) =>
                    {
                        OnEndedTransitionOfNewPresenter(oldPresenter, newPresenter, origin, container);
                        OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                    });
                }
                else
                {
                    OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                }
                break;

            case TransitionOrder.NewFirst:
                if (newStoryboard != null && newPresenter != null)
                {
                    this.BeginTransition(newStoryboard, newPresenter, container, (s, e) =>
                    {
                        //s.Seek(e, TimeSpan.Zero, TimeSeekOrigin.BeginTime);
                        s.Remove(e);
                        OnEndedTransitionOfNewPresenter(oldPresenter, newPresenter, origin, container);
                        if (oldStoryboard != null && oldPresenter != null)
                        {
                            this.BeginTransition(oldStoryboard, oldPresenter, container, (s1, e1) =>
                            {
                                OnEndedTransitionOfOldPresenter(oldPresenter, newPresenter, origin, container);
                                OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                            });
                        }
                        else
                        {
                            OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                        }
                    });
                }
                else if (oldStoryboard != null && oldPresenter != null)
                {
                    this.BeginTransition(oldStoryboard, oldPresenter, container, (s, e) =>
                    {
                        OnEndedTransitionOfOldPresenter(oldPresenter, newPresenter, origin, container);
                        OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                    });
                }
                else
                {
                    OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
                }
                break;

            default:
                break;
            }
        }
Beispiel #12
0
 protected virtual Storyboard PrepareStoryboardForNewPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     if (_newPresenterStoryboard == null)
     {
         _newPresenterStoryboard = CreateStoryboardForNewPresenter(container);
     }
     return(_newPresenterStoryboard);
 }
Beispiel #13
0
 protected virtual Storyboard CreateStoryboardForNewPresenter(ITransitionContainer container) => null;
Beispiel #14
0
        private void BeginTransition(Storyboard storyboard, FrameworkElement element, ITransitionContainer container, Action <Storyboard, FrameworkElement> onEndAction)
        {
            if (storyboard == null || element == null)
            {
                throw new Exception();
            }
            EventHandler endHandler = null;

            endHandler = (s, e) =>
            {
                onEndAction.Invoke(storyboard, element);
                storyboard.Completed        -= endHandler;
                container.TransitionChanged -= endHandler;
            };
            storyboard.Completed        += endHandler;
            container.TransitionChanged += endHandler;
            storyboard.Begin(element, true);
        }
Beispiel #15
0
 protected override Storyboard CreateStoryboardForNewPresenter(ITransitionContainer container) => NewStoryboard?.Clone();
Beispiel #16
0
 public ITransitionWipe ProviderTransitionWipeFrom(FrameworkElement oldPresenter, FrameworkElement newPresenter, ITransitionContainer container)
 {
     return(container.Indexof(newPresenter) > container.Indexof(oldPresenter) ? ForwardWipe : BackwardWipe);
 }
Beispiel #17
0
        protected override Storyboard PrepareStoryboardForNewPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
        {
            var horizontalProportion = Math.Max(1.0 - origin.X, 1.0 * origin.X);
            var verticalProportion   = Math.Max(1.0 - origin.Y, 1.0 * origin.Y);
            var radius             = Math.Sqrt(Math.Pow(newPresenter.ActualWidth * horizontalProportion, 2) + Math.Pow(newPresenter.ActualHeight * verticalProportion, 2));
            var scaleTransform     = new ScaleTransform(0, 0);
            var translateTransform = new TranslateTransform(newPresenter.ActualWidth * origin.X, newPresenter.ActualHeight * origin.Y);
            var transformGroup     = new TransformGroup();

            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(translateTransform);
            var ellipseGeomotry = new EllipseGeometry()
            {
                RadiusX   = radius,
                RadiusY   = radius,
                Transform = transformGroup
            };

            newPresenter.SetCurrentValue(UIElement.ClipProperty, ellipseGeomotry);
            return(base.PrepareStoryboardForNewPresenter(oldPresenter, newPresenter, origin, container));
        }
Beispiel #18
0
 protected override void OnCompletedTransition(Storyboard oldStoryboard, FrameworkElement oldPresenter, Storyboard newStoryboard, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     RemoveStyle(oldPresenter);
     RemoveStyle(newPresenter);
     base.OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
 }
Beispiel #19
0
 protected override Storyboard PrepareStoryboardForNewPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     if (NewPresenterStyle != null)
     {
         ApplyStyle(newPresenter, NewPresenterStyle);
     }
     return(base.PrepareStoryboardForNewPresenter(oldPresenter, newPresenter, origin, container));
 }
Beispiel #20
0
 protected override void OnCompletedTransition(Storyboard oldStoryboard, FrameworkElement oldPresenter, Storyboard newStoryboard, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     oldPresenter.RenderTransform = null;
     newPresenter.RenderTransform = null;
     base.OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
 }
Beispiel #21
0
        protected override Storyboard PrepareStoryboardForOldPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
        {
            var scaleTransform = new ScaleTransform(1, 1);

            oldPresenter.RenderTransform = scaleTransform;
            return(base.PrepareStoryboardForOldPresenter(oldPresenter, newPresenter, origin, container));
        }
Beispiel #22
0
 protected override void OnCompletedTransition(Storyboard oldStoryboard, FrameworkElement oldPresenter, Storyboard newStoryboard, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     newPresenter.SetCurrentValue(UIElement.ClipProperty, null);
     oldPresenter.RenderTransform = null;
     newPresenter.RenderTransform = null;
     oldPresenter.Opacity         = 1;
     base.OnCompletedTransition(oldStoryboard, oldPresenter, newStoryboard, newPresenter, origin, container);
 }
Beispiel #23
0
        protected override Storyboard PrepareStoryboardForNewPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
        {
            var toTransform = new TranslateTransform(0, 0);

            newPresenter.RenderTransform = toTransform;
            return(base.PrepareStoryboardForNewPresenter(oldPresenter, newPresenter, origin, container));
        }
Beispiel #24
0
 protected virtual void OnEndedTransitionOfNewPresenter(FrameworkElement oldPresenter, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
 }
Beispiel #25
0
 public ITransitionWipe ProviderTransitionWipeFrom(FrameworkElement oldPresenter, FrameworkElement newPresenter, ITransitionContainer container)
 {
     if (Wipes.Count > 0)
     {
         return(Wipes[_random.Next(0, Wipes.Count - 1)]);
     }
     else
     {
         return(_wipes[_random.Next(0, _wipes.Count - 1)]);
     }
 }
Beispiel #26
0
 protected virtual void OnCompletedTransition(Storyboard oldStoryboard, FrameworkElement oldPresenter, Storyboard newStoryboard, FrameworkElement newPresenter, Point origin, ITransitionContainer container)
 {
     if (oldPresenter != null)
     {
         oldPresenter.Visibility = Visibility.Hidden;
     }
     if (newPresenter != null)
     {
         newPresenter.Visibility = Visibility.Visible;
     }
     container.SetZIndexOrderBy(newPresenter, oldPresenter);
     container.OnCompletedTransition();
     oldStoryboard?.Remove(oldPresenter);
     newStoryboard?.Remove(newPresenter);
 }