欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

程序運行環(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)建一個幻燈片文檔(新建的文檔已默認包含一頁幻燈片)
            Presentation ppt = new Presentation();
            ISlide slide = ppt.Slides[0];//獲取第一頁空白幻燈片

            //添加形狀(指定形狀坐標、大小及相關(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)建一個幻燈片文檔(新建的文檔已默認包含一頁幻燈片)
            Dim ppt As New Presentation()
            Dim slide As ISlide = ppt.Slides(0)
            '獲取第一頁空白幻燈片
            '添加形狀(指定形狀坐標、大小及相關(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動畫路徑的步驟的詳細內(nèi)容,更多關(guān)于C#/VB.NET 自定義PPT動畫路徑的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • winform 調(diào)用攝像頭掃碼識別二維碼的實現(xiàn)步驟

    winform 調(diào)用攝像頭掃碼識別二維碼的實現(xiàn)步驟

    這篇文章主要介紹了winform 調(diào)用攝像頭掃碼識別二維碼的實現(xiàn)步驟,幫助大家更好的理解和學習使用winform,感興趣的朋友可以了解下
    2021-02-02
  • C#無損高質(zhì)量壓縮圖片實現(xiàn)代碼

    C#無損高質(zhì)量壓縮圖片實現(xiàn)代碼

    這篇文章主要為大家詳細介紹了C#無損高質(zhì)量壓縮圖片的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • C#處理文本文件TXT實例詳解

    C#處理文本文件TXT實例詳解

    這篇文章主要介紹了C#處理文本文件TXT的方法,以實例形式詳細分析了txt文本文件的讀取、修改及打印等功能的實現(xiàn)技巧,需要的朋友可以參考下
    2015-02-02
  • C#實現(xiàn)簡單打字小游戲

    C#實現(xiàn)簡單打字小游戲

    這篇文章主要為大家詳細介紹了C#實現(xiàn)簡單打字小游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • C#實現(xiàn)QQ郵箱發(fā)送郵件

    C#實現(xiàn)QQ郵箱發(fā)送郵件

    今天小編就為大家分享一篇關(guān)于C#實現(xiàn)QQ郵箱發(fā)送郵件,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • C#?Chart?簡單使用教程

    C#?Chart?簡單使用教程

    Chart控件可以用來繪制波形圖、柱狀圖、餅圖、折線圖等,用來進行數(shù)據(jù)表現(xiàn)是很不錯的,現(xiàn)在簡單說一下這個控件的使用方法,對C#?Chart使用相關(guān)知識感興趣的朋友一起看看吧
    2022-11-11
  • C#實現(xiàn)聊天消息渲染與圖文混排詳解

    C#實現(xiàn)聊天消息渲染與圖文混排詳解

    在實現(xiàn)聊天軟件時,渲染文字表情圖文混排是一項非常繁瑣的工作,再加上還要支持GIF動圖、引用消息、撤回消息、名片等不同樣式的消息渲染時,就更加麻煩了。本文就來和大家分享一下具體實現(xiàn)方法,希望對大家有所幫助
    2023-02-02
  • C# Ado.net實現(xiàn)讀取SQLServer數(shù)據(jù)庫存儲過程列表及參數(shù)信息示例

    C# Ado.net實現(xiàn)讀取SQLServer數(shù)據(jù)庫存儲過程列表及參數(shù)信息示例

    這篇文章主要介紹了C# Ado.net實現(xiàn)讀取SQLServer數(shù)據(jù)庫存儲過程列表及參數(shù)信息,結(jié)合實例形式總結(jié)分析了C#針對SQLServer數(shù)據(jù)庫存儲過程及參數(shù)信息的各種常見操作技巧,需要的朋友可以參考下
    2019-02-02
  • C#實現(xiàn)獲取Excel中圖片所在坐標位置

    C#實現(xiàn)獲取Excel中圖片所在坐標位置

    本文以C#和vb.net代碼示例展示如何來獲取Excel工作表中圖片的坐標位置,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2022-04-04
  • 小白2分鐘學會Visual Studio如何將引用包打包到NuGet上

    小白2分鐘學會Visual Studio如何將引用包打包到NuGet上

    這篇文章主要介紹了小白2分鐘學會Visual Studio如何將引用包打包到NuGet上,只需兩步完成打包上傳操作,需要的朋友可以參考下
    2021-09-09

最新評論