Пример #1
0
        /// <summary>
        /// Merges multiple animated slides into a single slide.
        /// TODO: Test this method more thoroughly, in places other than autozoom.
        /// </summary>
        public static void SquashSlides(IEnumerable <PowerPointSlide> slides)
        {
            PowerPointSlide  firstSlide      = null;
            ShapeRange       previousShapes  = null;
            EffectTransition slideTransition = new EffectTransition();

            foreach (PowerPointSlide slide in slides)
            {
                if (firstSlide == null)
                {
                    firstSlide      = slide;
                    slideTransition = GetTransitionFromSlide(slide);

                    firstSlide.Transition.AdvanceOnClick = MsoTriState.msoTrue;
                    firstSlide.Transition.AdvanceOnTime  = MsoTriState.msoFalse;

                    previousShapes = ShapeUtil.GetShapesWhenTypeNotMatches(firstSlide, firstSlide.Shapes.Range(), MsoShapeType.msoPlaceholder);
                    continue;
                }

                Sequence effectSequence   = firstSlide.GetNativeSlide().TimeLine.MainSequence;
                int      effectStartIndex = effectSequence.Count + 1;

                slide.DeleteIndicator();
                ShapeRange newShapeRange = firstSlide.CopyShapesToSlide(slide.Shapes.Range());
                newShapeRange.ZOrder(MsoZOrderCmd.msoSendToBack);

                foreach (Shape shape in newShapeRange)
                {
                    AddAppearAnimation(shape, firstSlide, effectStartIndex);
                }
                foreach (Shape shape in previousShapes)
                {
                    AddDisappearAnimation(shape, firstSlide, effectStartIndex);
                }
                slideTransition.ApplyTransition(effectSequence[effectStartIndex]);

                previousShapes  = newShapeRange;
                slideTransition = GetTransitionFromSlide(slide);
                slide.Delete();
            }
        }