Exemplo n.º 1
0
        public PowerPointSlide CreateStepBackSlide()
        {
            Slide duplicatedSlide = _slide.Duplicate()[1];

            return(PowerPointStepBackSlide.FromSlideFactory(duplicatedSlide));
        }
Exemplo n.º 2
0
        public static void AddStepBackAnimation(PowerPoint.Shape selectedShape, PowerPointSlide currentSlide,
            out PowerPointStepBackSlide addedSlide, bool includeAckSlide = true, bool deletePreviouslyAdded = true)
        {
            try
            {
                if (currentSlide == null || currentSlide.Index == 1)
                {
                    System.Windows.Forms.MessageBox.Show("No previous slide is found. Please select the correct slide", "Unable to Add Animations");
                    addedSlide = null;
                    return;
                }

                //Pick up the border and shadow style, to be applied to zoomed shape
                selectedShape.PickUp();
                PrepareZoomShape(currentSlide, ref selectedShape);
                PowerPointSlide previousSlide = GetPreviousSlide(currentSlide, deletePreviouslyAdded);

                PowerPoint.Shape previousSlidePicture = null, shapeToZoom = null;
                
                currentSlide.HideIndicator();
                if (backgroundZoomChecked)
                {
                    previousSlidePicture = GetPreviousSlidePictureWithBackground(currentSlide, previousSlide);
                    previousSlidePicture.Apply();
                    PreparePreviousSlidePicture(currentSlide, selectedShape, ref previousSlidePicture);

                    addedSlide = (PowerPointStepBackSlide)previousSlide.CreateStepBackSlide();
                    addedSlide.DeleteAllShapes();

                    PowerPoint.Shape backgroundShape = null;
                    shapeToZoom = GetStepBackWithBackgroundShapeToZoom(currentSlide, addedSlide, previousSlidePicture, out backgroundShape);
                    shapeToZoom.Apply();

                    addedSlide.PrepareForStepBack();
                    addedSlide.AddStepBackAnimationBackground(shapeToZoom, backgroundShape, previousSlidePicture);
                }
                else
                {
                    addedSlide = (PowerPointStepBackSlide)previousSlide.CreateStepBackSlide();
                    addedSlide.DeleteAllShapes();

                    shapeToZoom = GetStepBackWithoutBackgroundShapeToZoom(currentSlide, addedSlide, previousSlide);
                    shapeToZoom.Apply();
                    shapeToZoom.Copy();
                    previousSlidePicture = currentSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
                    previousSlidePicture.Apply();
                    PreparePreviousSlidePicture(currentSlide, selectedShape, ref previousSlidePicture);

                    addedSlide.PrepareForStepBack();
                    addedSlide.AddStepBackAnimationNonBackground(shapeToZoom, previousSlidePicture);
                }
                currentSlide.ShowIndicator();

                currentSlide.Transition.EntryEffect = PowerPoint.PpEntryEffect.ppEffectFadeSmoothly;
                currentSlide.Transition.Duration = 0.25f;
                Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index);
                Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview");
                if (includeAckSlide) PowerPointPresentation.Current.AddAckSlide();
            }
            catch (Exception e)
            {
                PowerPointLabsGlobals.LogException(e, "AddStepBackAnimation");
                ErrorDialogWrapper.ShowDialog("Error when adding step back animation", "An error occurred when adding step back animation.", e);
                throw;
            }
        }