Add Exit Animation Effect to a Shape in PowerPoint in C#

2018-08-02 08:28:43 Written by  support iceblue
Rate this item
(0 votes)

In Spire.Presentation, when we add a common animation effect that belongs to both entrance and exit types, it’s applied as entrance effect by default. This article is going to show you how to add exit animation effect to a shape in PowerPoint using Spire.Presentation.

Detail steps:

Step 1: Create a Presentation instance and get the first slide.

Presentation ppt = new Presentation();
ISlide slide = ppt.Slides[0];

Step 2: Add a shape to the slide.

IShape starShape = slide.Shapes.AppendShape(ShapeType.FivePointedStar, new RectangleF(100, 100, 200, 200));

Step 3: Add random bars effect to the shape.

AnimationEffect effect = slide.Timeline.MainSequence.AddEffect(starShape, AnimationEffectType.RandomBars);

Step 4: Change the type of the effect from entrance to exit.

effect.PresetClassType = TimeNodePresetClassType.Exit;

Step 5: Save the file.

ppt.SaveToFile("ExitAnimationEffect.pptx", FileFormat.Pptx2013);

Screenshot:

Add Exit Animation Effect to a Shape in PowerPoint in C#

Full code:

using Spire.Presentation;
using Spire.Presentation.Drawing.Animation;
using System.Drawing;

namespace AddExitAnimationEffect
{

    class Program
    {

        static void Main(string[] args)
        {
            {
                //Create a Presentation instance
                Presentation ppt = new Presentation();

                //Get the first slide
                ISlide slide = ppt.Slides[0];

                //Add a shape to the slide
                IShape starShape = slide.Shapes.AppendShape(ShapeType.FivePointedStar, new RectangleF(100, 100, 200, 200));

                //Add random bars effect to the shape
                AnimationEffect effect = slide.Timeline.MainSequence.AddEffect(starShape, AnimationEffectType.RandomBars);

                //Change effect type from entrance to exit
                effect.PresetClassType = TimeNodePresetClassType.Exit;

                //Save the file
                ppt.SaveToFile("ExitAnimationEffect.pptx", FileFormat.Pptx2013);



            }
        }

    }
}

Additional Info

  • tutorial_title:
Last modified on Tuesday, 27 August 2024 07:38