Пример #1
0
        private void ApplyTransitionEffect()
        {
            TransitionEffect[] effectGroup = transitionEffects[this.rand.Next(transitionEffects.Length)];
            TransitionEffect   effect      = effectGroup[this.rand.Next(effectGroup.Length)];

            if (_useOrder)
            {
                effectGroup = transitionEffectsSingle[_nextEffect % transitionEffectsSingle.Length];
                effect      = effectGroup[0];

                if (++_usedTimes == 2)
                {
                    _usedTimes = 0;
                    _nextEffect++;
                }

                this.effectName.Text = ExtractName(effect);
                if (_nextEffect == transitionEffectsSingle.Length)
                {
                    _useOrder            = false;
                    this.effectName.Text = "mixed effects, random";
                }
            }


            RandomizedTransitionEffect randEffect = effect as RandomizedTransitionEffect;

            if (randEffect != null)
            {
                randEffect.RandomSeed = this.rand.NextDouble();
            }

            DoubleAnimation da = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(2.0)), FillBehavior.HoldEnd);

            da.AccelerationRatio = 0.5;
            da.DecelerationRatio = 0.5;
            da.Completed        += new EventHandler(this.TransitionCompleted);
            effect.BeginAnimation(TransitionEffect.ProgressProperty, da);

            VisualBrush vb = new VisualBrush(this.oldChild);

            vb.Viewbox      = new Rect(0, 0, this.oldChild.ActualWidth, this.oldChild.ActualHeight);
            vb.ViewboxUnits = BrushMappingMode.Absolute;
            //this.oldChild.Width = this.oldChild.ActualWidth;
            //this.oldChild.Height = this.oldChild.ActualHeight;
            //this.oldChild.Measure(new Size(this.oldChild.ActualWidth, this.oldChild.ActualHeight));
            //this.oldChild.Arrange(new Rect(0, 0, this.oldChild.ActualWidth, this.oldChild.ActualHeight));

            effect.OldImage          = vb;
            this.currentChild.Effect = effect;
        }
Пример #2
0
        private void ApplyTransitionEffect()
        {
            TransitionEffect[] effectGroup = transitionEffects[this.rand.Next(transitionEffects.Length)];
            TransitionEffect   effect      = effectGroup[this.rand.Next(effectGroup.Length)];

            if (_useOrder)
            {
                effectGroup = transitionEffectsSingle[_nextEffect % transitionEffectsSingle.Length];
                effect      = effectGroup[0];

                if (++_usedTimes == 2)
                {
                    _usedTimes = 0;
                    _nextEffect++;
                }

                this.effectName.Text = ExtractName(effect);
                if (_nextEffect == transitionEffectsSingle.Length)
                {
                    _useOrder            = false;
                    this.effectName.Text = "mixed effects, random";
                }
            }


            RandomizedTransitionEffect randEffect = effect as RandomizedTransitionEffect;

            if (randEffect != null)
            {
                randEffect.RandomSeed = this.rand.NextDouble();
            }


            ImageBrush ib = new ImageBrush();

            ib.ImageSource  = this.oldChild.Source;
            effect.OldImage = ib;
            Storyboard sb = TransitionHelper.CreateTransition(effect, this.currentChild, TimeSpan.FromSeconds(1),
                                                              0, 1, ib);

            sb.Completed += new EventHandler(this.TransitionCompleted);
            sb.Begin();
        }