2

我正在向 PowerPoint 幻灯片中添加一些对象以及一些动画。问题是当我在添加第一个对象后添加任何对象时,先前添加的对象和当前对象都带有动画。如何让我之前添加的对象保持原样,只有新的对象带有动画,这是我正在使用的一些代码,

private void AddShapeToSlide(int left, int top, int width, int height)
{
    Slide slide = GetCurrentSlide();
    Shape shape = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, left, top, width, height);
    ApplyAnimation(slide, shape);
    shape.ZOrder(MsoZOrderCmd.msoBringToFront);
    _presentation.SlideShowWindow.Activate();
}

private void ApplyAnimation(Slide slide, Shape shape)
{
    shape.AnimationSettings.AdvanceMode = PpAdvanceMode.ppAdvanceOnTime;
    shape.AnimationSettings.AdvanceTime = 0;
    shape.AnimationSettings.Animate = MsoTriState.msoTrue;
    shape.AnimationSettings.EntryEffect = GetPowerPointTransition();

    Effect effect = slide.TimeLine.MainSequence.FindFirstAnimationFor(shape);
    if (effect != null && shape.AnimationSettings.EntryEffect != PpEntryEffect.ppEffectNone)
    {
         effect.Timing.Duration = 5;
    }
}

任何帮助或想法都很有价值。提前致谢。

4

0 回答 0