最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#/VB.NET 自定義PPT動畫路徑的步驟

 更新時間:2021年05月10日 10:33:49   作者:E-iceblue  
這篇文章主要介紹了C#/VB.NET 自定義PPT動畫路徑的步驟,幫助大家更好的理解和學(xué)習(xí)使用c#,感興趣的朋友可以了解下

PPT中的動畫效果可分為已有內(nèi)置動畫以及自定義動畫。設(shè)置內(nèi)置動畫,只需直接指定動畫效果類型即可。本文主要介紹如何實(shí)現(xiàn)自定義動畫,即自定義形狀動作線性路徑。附C#及VB.NET代碼供參考。

程序運(yùn)行環(huán)境如下:

  • .Net Framework 4.8
  • Visual Studio
  • Spire.Presentation.dll 6.4.5

所需引用的必要程序集文件如下圖:

C#

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

namespace CustomAnimation
{
    class Program
    {
        static void Main(string[] args)
        {
            //創(chuàng)建一個幻燈片文檔(新建的文檔已默認(rèn)包含一頁幻燈片)
            Presentation ppt = new Presentation();
            ISlide slide = ppt.Slides[0];//獲取第一頁空白幻燈片

            //添加形狀(指定形狀坐標(biāo)、大小及相關(guān)格式設(shè)置)
            IAutoShape shape = slide.Shapes.AppendShape(ShapeType.FivePointedStar, new RectangleF(100, 50, 180, 180));
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient;
            shape.Fill.Gradient.GradientStops.Append(0, KnownColors.SkyBlue);
            shape.Fill.Gradient.GradientStops.Append(1, KnownColors.Pink);
            shape.ShapeStyle.LineColor.Color = Color.White;

            //給形狀設(shè)置動畫效果
            AnimationEffect effect = ppt.Slides[0].Timeline.MainSequence.AddEffect(shape, AnimationEffectType.PathUser);
            CommonBehaviorCollection common = effect.CommonBehaviorCollection;
            AnimationMotion motion = (AnimationMotion)common[0];
            motion.Origin = AnimationMotionOrigin.Layout;
            motion.PathEditMode = AnimationMotionPathEditMode.Relative;
            MotionPath moinPath = new MotionPath();
            moinPath.Add(MotionCommandPathType.MoveTo, new PointF[] { new PointF(0, 0) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(0.18f, 0.18f) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(-0.1f, 0.2f) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(0.25f, 0.2f) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.End, new PointF[] { }, MotionPathPointsType.CurveStraight, true);
            motion.Path = moinPath;

            //保存文檔
            ppt.SaveToFile("CustomAnimation.pptx", FileFormat.Pptx2013);
            System.Diagnostics.Process.Start("CustomAnimation.pptx");
        }
    }
}

VB.NET

Imports Spire.Presentation
Imports Spire.Presentation.Collections
Imports Spire.Presentation.Drawing.Animation
Imports System.Drawing

Namespace CustomAnimation
    Class Program
        Private Shared Sub Main(args As String())
            '創(chuàng)建一個幻燈片文檔(新建的文檔已默認(rèn)包含一頁幻燈片)
            Dim ppt As New Presentation()
            Dim slide As ISlide = ppt.Slides(0)
            '獲取第一頁空白幻燈片
            '添加形狀(指定形狀坐標(biāo)、大小及相關(guān)格式設(shè)置)
            Dim shape As IAutoShape = slide.Shapes.AppendShape(ShapeType.FivePointedStar, New RectangleF(100, 50, 180, 180))
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient
            shape.Fill.Gradient.GradientStops.Append(0, KnownColors.SkyBlue)
            shape.Fill.Gradient.GradientStops.Append(1, KnownColors.Pink)
            shape.ShapeStyle.LineColor.Color = Color.White

            '給形狀設(shè)置動畫效果
            Dim effect As AnimationEffect = ppt.Slides(0).Timeline.MainSequence.AddEffect(shape, AnimationEffectType.PathUser)
            Dim common As CommonBehaviorCollection = effect.CommonBehaviorCollection
            Dim motion As AnimationMotion = DirectCast(common(0), AnimationMotion)
            motion.Origin = AnimationMotionOrigin.Layout
            motion.PathEditMode = AnimationMotionPathEditMode.Relative
            Dim moinPath As New MotionPath()
            moinPath.Add(MotionCommandPathType.MoveTo, New PointF() {New PointF(0, 0)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.LineTo, New PointF() {New PointF(0.18F, 0.18F)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.LineTo, New PointF() {New PointF(-0.1F, 0.2F)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.LineTo, New PointF() {New PointF(0.25F, 0.2F)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.[End], New PointF() {}, MotionPathPointsType.CurveStraight, True)
            motion.Path = moinPath

            '保存文檔
            ppt.SaveToFile("CustomAnimation.pptx", FileFormat.Pptx2013)
            System.Diagnostics.Process.Start("CustomAnimation.pptx")
        End Sub
    End Class
End Namespace

動畫效果:

以上就是C#/VB.NET 自定義PPT動畫路徑的步驟的詳細(xì)內(nèi)容,更多關(guān)于C#/VB.NET 自定義PPT動畫路徑的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論

伊宁县| 和顺县| 东辽县| 怀宁县| 长阳| 高碑店市| 南华县| 汉寿县| 林西县| 沅江市| 阳江市| 安乡县| 淮滨县| 宁陵县| 长沙县| 通道| 元阳县| 沂南县| 罗平县| 沈阳市| 六枝特区| 喀喇| 丹凤县| 吴川市| 镇江市| 山西省| 剑河县| 广水市| 白城市| 长沙市| 高雄市| 林甸县| 肇源县| 交城县| 土默特左旗| 秭归县| 崇明县| 柯坪县| 修水县| 西宁市| 建宁县|