private static PowerPoint.Effect AddMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialX, float initialY, float finalX, float finalY, float duration, ref PowerPoint.MsoAnimTriggerType trigger)
        {
            if ((finalX != initialX) || (finalY != initialY))
            {
                PowerPoint.Effect            effectMotion = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectPathDown, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger);
                PowerPoint.AnimationBehavior motion       = effectMotion.Behaviors[1];
                effectMotion.Timing.Duration = duration;
                trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;

                //Create VML path for the motion path
                //This path needs to be a curved path to allow the user to edit points
                float point1X = ((finalX - initialX) / 2f) / PowerPointPresentation.Current.SlideWidth;
                float point1Y = ((finalY - initialY) / 2f) / PowerPointPresentation.Current.SlideHeight;
                float point2X = (finalX - initialX) / PowerPointPresentation.Current.SlideWidth;
                float point2Y = (finalY - initialY) / PowerPointPresentation.Current.SlideHeight;
                motion.MotionEffect.Path = "M 0 0 C "
                                           + point1X.ToString(CultureInfo.InvariantCulture) + " "
                                           + point1Y.ToString(CultureInfo.InvariantCulture) + " "
                                           + point1X.ToString(CultureInfo.InvariantCulture) + " "
                                           + point1Y.ToString(CultureInfo.InvariantCulture) + " "
                                           + point2X.ToString(CultureInfo.InvariantCulture) + " "
                                           + point2Y.ToString(CultureInfo.InvariantCulture) + " E";
                effectMotion.Timing.SmoothStart = Office.MsoTriState.msoFalse;
                effectMotion.Timing.SmoothEnd   = Office.MsoTriState.msoFalse;
                return(effectMotion);
            }
            return(null);
        }
 private static PowerPoint.Effect AddRotationAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialRotation, float finalRotation, float duration, ref PowerPoint.MsoAnimTriggerType trigger)
 {
     if (finalRotation != initialRotation)
     {
         PowerPoint.Effect            effectRotate = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectSpin, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger);
         PowerPoint.AnimationBehavior rotate       = effectRotate.Behaviors[1];
         effectRotate.Timing.Duration         = duration;
         effectRotate.EffectParameters.Amount = LegacyShapeUtil.GetMinimumRotation(initialRotation, finalRotation);
         trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
         return(effectRotate);
     }
     return(null);
 }
        private void AddSliderMotionEffect(Shape shape, int duration, float timerWidth, float slideWidth, PowerPoint.MsoAnimTriggerType trigger)
        {
            PowerPoint.Effect sliderMotionEffect = this.GetCurrentSlide().TimeLine.MainSequence.AddEffect(
                shape,
                PowerPoint.MsoAnimEffect.msoAnimEffectPathRight,
                PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone,
                trigger);
            PowerPoint.AnimationBehavior motion = sliderMotionEffect.Behaviors[1];
            float end = timerWidth / slideWidth;

            motion.MotionEffect.Path              = "M 0 0 L " + end + " 0 E";
            sliderMotionEffect.Timing.Duration    = duration;
            sliderMotionEffect.Timing.SmoothStart = Microsoft.Office.Core.MsoTriState.msoFalse;
            sliderMotionEffect.Timing.SmoothEnd   = Microsoft.Office.Core.MsoTriState.msoFalse;
        }
 private void AddProgressBarAnimation(int duration)
 {
     PowerPoint.Effect progressBarMotionEffect = this.GetCurrentSlide().TimeLine.MainSequence.AddEffect(
         progressBar,
         PowerPoint.MsoAnimEffect.msoAnimEffectGrowShrink,
         PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone,
         PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
     progressBarMotionEffect.Timing.Duration    = duration;
     progressBarMotionEffect.Timing.SmoothStart = Microsoft.Office.Core.MsoTriState.msoFalse;
     progressBarMotionEffect.Timing.SmoothEnd   = Microsoft.Office.Core.MsoTriState.msoFalse;
     PowerPoint.AnimationBehavior shrinkBehavior = progressBarMotionEffect.Behaviors[1];
     // Shrink width to 0
     shrinkBehavior.ScaleEffect.ByX = 0f;
     shrinkBehavior.ScaleEffect.ByY = 100f;
 }
Пример #5
0
        private static PowerPoint.Effect AddResizeAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialWidth, float initialHeight, float finalWidth, float finalHeight, float duration, ref PowerPoint.MsoAnimTriggerType trigger)
        {
            if ((finalWidth != initialWidth) || (finalHeight != initialHeight))
            {
                animationShape.LockAspectRatio = Office.MsoTriState.msoFalse;
                PowerPoint.Effect            effectResize = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectGrowShrink, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger);
                PowerPoint.AnimationBehavior resize       = effectResize.Behaviors[1];

                effectResize.Timing.Duration = duration;

                resize.ScaleEffect.ByX = (finalWidth / initialWidth) * 100;
                resize.ScaleEffect.ByY = (finalHeight / initialHeight) * 100;

                trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
                return(effectResize);
            }
            return(null);
        }