C#PowerPoint中如何添加、修改和刪除動(dòng)畫

小編給大家分享一下C# PowerPoint中如何添加、修改和刪除動(dòng)畫,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

成都創(chuàng)新互聯(lián)公司是一家從事企業(yè)網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)制作的專業(yè)的建站公司,擁有經(jīng)驗(yàn)豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計(jì)人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實(shí)力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨(dú)特的設(shè)計(jì)風(fēng)格。自公司成立以來曾獨(dú)立設(shè)計(jì)制作的站點(diǎn)成百上千。

為了讓PowerPoint文檔更加精美,在制作文檔的過程中,我們通常會(huì)給PowerPoint文檔中的元素如形狀、圖片、表格等添加動(dòng)畫。本文將介紹如何使用.NET PowerPoint組件Spire.Presentation和C#編程的方式給PowerPoint中的形狀添加動(dòng)畫,并修改和刪除現(xiàn)有動(dòng)畫。

在開始前我們可以了解一下PowerPoint中的動(dòng)畫。在PowerPoint中,動(dòng)畫大致可分為以下四大類:

1.  進(jìn)入

2.  強(qiáng)調(diào)

3.  退出

4.  動(dòng)作路徑

其中進(jìn)入、強(qiáng)調(diào)和退出類型下有多種不同的預(yù)設(shè)動(dòng)畫效果,有些動(dòng)畫效果還可以添加子效果,例如“進(jìn)入”分類下的“隨機(jī)線條”動(dòng)畫效果,可以設(shè)置水平方向或垂直方向子效果(默認(rèn)為水平方向)。下圖展示了如何在PowerPoint中添加動(dòng)畫:

C# PowerPoint中如何添加、修改和刪除動(dòng)畫

如何在Spire.Presentation中添加動(dòng)畫

Spire.Presentation支持約151種動(dòng)畫效果(可以在AnimationEffectType枚舉中查看),這些動(dòng)畫效果及其所屬分類和子效果,請(qǐng)參見文末附表。

在使用以下代碼前,需要下載Spire.Presentation安裝, 并從安裝路徑下引用Spire.Presentation.dll到工程中(或可從NuGet搜索Spire.Presentation并安裝)。

添加動(dòng)畫

//加載文檔
Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");
 
//獲取第一張幻燈片
ISlide slide = ppt.Slides[0];
 
RectangleF rect = new RectangleF(50, 200, 200, 200);
//添加形狀到幻燈片
IShape cubeShape = slide.Shapes.AppendShape(ShapeType.Cube, rect);
 
//給形狀添加動(dòng)畫效果
AnimationEffectCollection sequence = slide.Timeline.MainSequence;
AnimationEffect effect = sequence.AddEffect(cubeShape, AnimationEffectType.Bounce);
 
//保存文檔
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);

 C# PowerPoint中如何添加、修改和刪除動(dòng)畫

通常我們添加的動(dòng)畫效果默認(rèn)是“進(jìn)入”效果,下面的代碼將介紹如何添加“退出”動(dòng)畫效果:

//加載文檔
Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");
 
//獲取第一張幻燈片
ISlide slide = ppt.Slides[0];
 
RectangleF rect = new RectangleF(50, 200, 200, 200);
//添加形狀到幻燈片
IShape cubeShape = slide.Shapes.AppendShape(ShapeType.Cube, rect);
 
//給形狀添加動(dòng)畫效果
AnimationEffectCollection sequence = slide.Timeline.MainSequence;
AnimationEffect effect = sequence.AddEffect(cubeShape, AnimationEffectType.RandomBars);
//將動(dòng)畫效果從默認(rèn)的“進(jìn)入”效果改為“退出”效果
effect.PresetClassType = TimeNodePresetClassType.Exit;
//給該動(dòng)畫添加子效果
effect.Subtype = AnimationEffectSubtype.Vertical;
 
//保存文檔
ppt.SaveToFile("ExitAnimationEffect.pptx", FileFormat.Pptx2013);

 C# PowerPoint中如何添加、修改和刪除動(dòng)畫

修改動(dòng)畫

對(duì)文檔中的現(xiàn)有動(dòng)畫,我們可以對(duì)其進(jìn)行修改。下面的代碼將介紹如何修改現(xiàn)有動(dòng)畫的類型和持續(xù)時(shí)間。

修改動(dòng)畫類型

//加載文檔
Presentation ppt = new Presentation();
ppt.LoadFromFile("Output.pptx");
 
//獲取第一張幻燈片
ISlide slide = ppt.Slides[0];
 
//修改第一個(gè)動(dòng)畫的類型
AnimationEffectCollection sequence = slide.Timeline.MainSequence;
sequence[0].AnimationEffectType = AnimationEffectType.GrowAndTurn;
 
//保存文本
ppt.SaveToFile("EditAnimationType.pptx", FileFormat.Pptx2013);

修改持續(xù)時(shí)間

//加載文檔
Presentation ppt = new Presentation();
ppt.LoadFromFile("Output.pptx");
 
//獲取第一張幻燈片
ISlide slide = ppt.Slides[0];
 
//修改第一個(gè)動(dòng)畫的持續(xù)時(shí)間
AnimationEffectCollection sequence = slide.Timeline.MainSequence;
sequence[0].Timing.Duration = 5;
 
//保存文檔
ppt.SaveToFile("EditAnimationTime.pptx", FileFormat.Pptx2013);

刪除動(dòng)畫

//加載文檔
Presentation ppt = new Presentation();
ppt.LoadFromFile("Output.pptx");
 
//獲取第一張幻燈片
ISlide slide = ppt.Slides[0];
 
//刪除第一個(gè)動(dòng)畫
AnimationEffectCollection sequence = slide.Timeline.MainSequence;
sequence.RemoveAt(0);
 
//保存文檔
ppt.SaveToFile("RemoveAnimation.pptx", FileFormat.Pptx2013);

附表(Spire.Presentation中動(dòng)畫效果及其所屬分類和子效果):

動(dòng)畫效果

分類

子效果

Appear

Entrance or Exit

EffectSubtype.None

CurveUpDown

Entrance or Exit

EffectSubtype.None

Ascend

Entrance or Exit

EffectSubtype.None

Blast

Emphasis

EffectSubtype.None

Blinds

Entrance or Exit

·  EffectSubtype.Horizontal

·  EffectSubtype.Vertical

Blink

Emphasis

EffectSubtype.None

BoldFlash

Emphasis

EffectSubtype.None

BoldReveal

Emphasis

EffectSubtype.None

Boomerang

Entrance or Exit

EffectSubtype.None

Bounce

Entrance or Exit

EffectSubtype.None

Box

Entrance or Exit

·  EffectSubtype.In

·  EffectSubtype.Out

BrushOnColor

Emphasis

EffectSubtype.None

BrushOnUnderline

Emphasis

EffectSubtype.None

CenterRevolve

Entrance or Exit

EffectSubtype.None

ChangeFillColor

Emphasis

·  EffectSubtype.Instant

·  EffectSubtype.Gradual

·    EffectSubtype.GradualAndCycleClockwise

·    EffectSubtype.GradualAndCycleCounterClockwise

ChangeFont

Emphasis

·  EffectSubtype.Instant

·  EffectSubtype.Gradual

ChangeFontColor

Emphasis

·  EffectSubtype.Instant

·  EffectSubtype.Gradual

·    EffectSubtype.GradualAndCycleClockwise

·    EffectSubtype.GradualAndCycleCounterClockwise

ChangeFontSize

Emphasis

·  EffectSubtype.Instant

·  EffectSubtype.Gradual

ChangeFontStyle

Emphasis

·  EffectSubtype.FontBold

·  EffectSubtype.FontItalic

·    EffectSubtype.FontUnderline

ChangeLineColor

Emphasis

·  EffectSubtype.Instant

·  EffectSubtype.Gradual

·    EffectSubtype.GradualAndCycleClockwise

·    EffectSubtype.GradualAndCycleCounterClockwise

Checkerboard

Entrance or Exit

·  EffectSubtype.Vertical

·  EffectSubtype.Across

Circle

Entrance or Exit

·  EffectSubtype.In

·  EffectSubtype.Out

ColorBlend

Emphasis

EffectSubtype.None

ColorTypewriter

Entrance or Exit

EffectSubtype.None

ColorWave

Emphasis

EffectSubtype.None

ComplementaryColor

Emphasis

EffectSubtype.None

ComplementaryColor2

Emphasis

EffectSubtype.None

Compress

Entrance or Exit

EffectSubtype.None

ContrastingColor

Emphasis

EffectSubtype.None

Crawl

Entrance or Exit

·  EffectSubtype.Right

·  EffectSubtype.Left

·  EffectSubtype.Top

·  EffectSubtype.Bottom

Credits

Entrance or Exit

EffectSubtype.None

Custom

-

-

Darken

Emphasis

EffectSubtype.None

Desaturate

Emphasis

EffectSubtype.None

Descend

Entrance or Exit

EffectSubtype.None

Diamond

Entrance or Exit

·  EffectSubtype.In

·  EffectSubtype.Out

Dissolve

Entrance or Exit

EffectSubtype.None

EaseInOut

Entrance or Exit

EffectSubtype.None

Expand

Entrance or Exit

EffectSubtype.None

Fade

Entrance or Exit

EffectSubtype.None

FadedSwivel

Entrance or Exit

EffectSubtype.None

FadedZoom

Entrance or Exit

·  EffectSubtype.None

·  EffectSubtype.Center

FlashBulb

Emphasis

EffectSubtype.None

FlashOnce

Entrance or Exit

EffectSubtype.None

Flicker

Emphasis

EffectSubtype.None

Flip

Entrance or Exit

EffectSubtype.None

Float

Entrance or Exit

EffectSubtype.None

Fly

Entrance or Exit

·  EffectSubtype.Right

·  EffectSubtype.Left

·  EffectSubtype.Top

·  EffectSubtype.Bottom

·  EffectSubtype.TopLeft

·  EffectSubtype.TopRight

·    EffectSubtype.BottomLeft

·  EffectSubtype.BottomRight

Fold

Entrance or Exit

EffectSubtype.None

Glide

Entrance or Exit

EffectSubtype.None

GrowAndTurn

Entrance or Exit

EffectSubtype.None

GrowShrink

Emphasis

EffectSubtype.None

GrowWithColor

Emphasis

EffectSubtype.None

Lighten

Emphasis

EffectSubtype.None

LightSpeed

Entrance or Exit

EffectSubtype.None

Path5PointStar

Path

EffectSubtype.None

Path6PointStar

Path

EffectSubtype.None

Path7PointStar

Path

EffectSubtype.None

Path8PointStar

Path

EffectSubtype.None

PathArcDown

Path

EffectSubtype.None

PathArcLeft

Path

EffectSubtype.None

PathArcRight

Path

EffectSubtype.None

PathArcUp

Path

EffectSubtype.None

PathBean

Path

EffectSubtype.None

PathBounceLeft

Path

EffectSubtype.None

PathBounceRight

Path

EffectSubtype.None

PathBuzzsaw

Path

EffectSubtype.None

PathCircle

Path

EffectSubtype.None

PathCrescentMoon

Path

EffectSubtype.None

PathCurvedSquare

Path

EffectSubtype.None

PathCurvedX

Path

EffectSubtype.None

PathCurvyLeft

Path

EffectSubtype.None

PathCurvyRight

Path

EffectSubtype.None

PathCurvyStar

Path

EffectSubtype.None

PathDecayingWave

Path

EffectSubtype.None

PathDiagonalDownRight

Path

EffectSubtype.None

PathDiagonalUpRight

Path

EffectSubtype.None

PathDiamond

Path

EffectSubtype.None

PathDown

Path

EffectSubtype.None

PathEqualTriangle

Path

EffectSubtype.None

PathFigure8Four

Path

EffectSubtype.None

PathFootball

Path

EffectSubtype.None

PathFunnel

Path

EffectSubtype.None

PathHeart

Path

EffectSubtype.None

PathHeartbeat

Path

EffectSubtype.None

PathHexagon

Path

EffectSubtype.None

PathHorizontalFigure8

Path

EffectSubtype.None

PathInvertedSquare

Path

EffectSubtype.None

PathInvertedTriangle

Path

EffectSubtype.None

PathLeft

Path

EffectSubtype.None

PathLoopdeLoop

Path

EffectSubtype.None

PathNeutron

Path

EffectSubtype.None

PathOctagon

Path

EffectSubtype.None

PathParallelogram

Path

EffectSubtype.None

PathPeanut

Path

EffectSubtype.None

PathPentagon

Path

EffectSubtype.None

PathPlus

Path

EffectSubtype.None

PathPointyStar

Path

EffectSubtype.None

PathRight

Path

EffectSubtype.None

PathRightTriangle

Path

EffectSubtype.None

PathSCurve1

Path

EffectSubtype.None

PathSCurve2

Path

EffectSubtype.None

PathSineWave

Path

EffectSubtype.None

PathSpiralLeft

Path

EffectSubtype.None

PathSpiralRight

Path

EffectSubtype.None

PathSpring

Path

EffectSubtype.None

PathSquare

Path

EffectSubtype.None

PathStairsDown

Path

EffectSubtype.None

PathSwoosh

Path

EffectSubtype.None

PathTeardrop

Path

EffectSubtype.None

PathTrapezoid

Path

EffectSubtype.None

PathTurnDown

Path

EffectSubtype.None

PathTurnRight

Path

EffectSubtype.None

PathTurnUp

Path

EffectSubtype.None

PathTurnUpRight

Path

EffectSubtype.None

PathUp

Path

EffectSubtype.None

PathUser

Path

EffectSubtype.None

PathVerticalFigure8

Path

EffectSubtype.None

PathWave

Path

EffectSubtype.None

PathZigzag

Path

EffectSubtype.None

Peek

Entrance or Exit

·  EffectSubtype.Bottom

·  EffectSubtype.Left

·  EffectSubtype.Right

·  EffectSubtype.Top

Pinwheel

Entrance or Exit

EffectSubtype.None

Plus

Entrance or Exit

·  EffectSubtype.In

·  EffectSubtype.Out

RandomBars

Entrance or Exit

·    EffectSubtype.Horizontal

·  EffectSubtype.Vertical

RandomEffects

Entrance or Exit

EffectSubtype.None

RiseUp

Entrance

EffectSubtype.None

Shimmer

Emphasis

EffectSubtype.None

Sling

Entrance or Exit

EffectSubtype.None

Spin

Emphasis

EffectSubtype.None

Spinner

Emphasis

EffectSubtype.None

Spiral

Entrance or Exit

EffectSubtype.None

Split

Entrance or Exit

·    EffectSubtype.HorizontalIn

·  EffectSubtype.HorizontalOut

·    EffectSubtype.VerticalIn

·    EffectSubtype.VerticalOut

Stretch

Entrance or Exit

·  EffectSubtype.Right

·  EffectSubtype.Left

·  EffectSubtype.Top

·  EffectSubtype.Bottom

·  EffectSubtype.Across

Strips

Entrance or Exit

·  EffectSubtype.UpLeft

·  EffectSubtype.UpRight

·  EffectSubtype.DownLeft

·    EffectSubtype.DownRight

StyleEmphasis

Emphasis

EffectSubtype.None

Swish

Entrance or Exit

EffectSubtype.None

Swivel

Entrance or Exit

·    EffectSubtype.Horizontal

·  EffectSubtype.Vertical

Teeter

Emphasis

EffectSubtype.None

Thread

Emphasis

EffectSubtype.None

Transparency

Emphasis

EffectSubtype.None

Unfold

Entrance or Exit

EffectSubtype.None

VerticalGrow

Emphasis

EffectSubtype.None

Wave

Emphasis

EffectSubtype.None

Wedge

Entrance or Exit

EffectSubtype.None

Wheel

Entrance or Exit

·  EffectSubtype.Wheel1

·  EffectSubtype.Wheel2

·  EffectSubtype.Wheel3

·  EffectSubtype.Wheel4

·  EffectSubtype.Wheel8

Whip

Entrance or Exit

EffectSubtype.None

Wipe

Entrance or Exit

·  EffectSubtype.Top

·  EffectSubtype.Right

·  EffectSubtype.Bottom

·  EffectSubtype.Left

Magnify

Entrance or Exit

EffectSubtype.None

Zoom

Entrance or Exit

·  EffectSubtype.In

·  EffectSubtype.Out

·  EffectSubtype.InCenter   - only for Entrance type

·  EffectSubtype.OutBottom   - only for Entrance type

·    EffectSubtype.OutSlightly

·    EffectSubtype.InSlightly

·    EffectSubtype.OutCenter - only for Exit type

·  EffectSubtype.InBottom   - only for Exit type

注:Entrance表示“進(jìn)入”, Exit表示“退出”,Emphasis表示“強(qiáng)調(diào)”,Path表示“動(dòng)作路徑”;EffectSubtype.None表示該效果無子效果。

以上是“C# PowerPoint中如何添加、修改和刪除動(dòng)畫”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站欄目:C#PowerPoint中如何添加、修改和刪除動(dòng)畫
當(dāng)前鏈接:http://muchs.cn/article10/ihisgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、網(wǎng)站維護(hù)、網(wǎng)站策劃外貿(mào)建站、網(wǎng)站制作、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)