亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C#/VB.NET 自定義PPT動(dòng)畫路徑的步驟

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

PPT中的動(dòng)畫效果可分為已有內(nèi)置動(dòng)畫以及自定義動(dòng)畫。設(shè)置內(nèi)置動(dòng)畫,只需直接指定動(dòng)畫效果類型即可。本文主要介紹如何實(shí)現(xiàn)自定義動(dòng)畫,即自定義形狀動(dòng)作線性路徑。附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)建一個(gè)幻燈片文檔(新建的文檔已默認(rèn)包含一頁(yè)幻燈片)
            Presentation ppt = new Presentation();
            ISlide slide = ppt.Slides[0];//獲取第一頁(yè)空白幻燈片

            //添加形狀(指定形狀坐標(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è)置動(dòng)畫效果
            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)建一個(gè)幻燈片文檔(新建的文檔已默認(rèn)包含一頁(yè)幻燈片)
            Dim ppt As New Presentation()
            Dim slide As ISlide = ppt.Slides(0)
            '獲取第一頁(yè)空白幻燈片
            '添加形狀(指定形狀坐標(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è)置動(dòng)畫效果
            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

動(dòng)畫效果:

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

相關(guān)文章

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

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

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

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

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

    C#處理文本文件TXT實(shí)例詳解

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

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

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

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

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

    C#?Chart?簡(jiǎn)單使用教程

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

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

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

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

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

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

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

    小白2分鐘學(xué)會(huì)Visual Studio如何將引用包打包到NuGet上

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

最新評(píng)論