C# PPT 为形状设置三维效果
2015-08-27 11:03
316 查看
在PPT中,形状是非常重要的元素。3-D形状,立体多元,给人耳目一新的感觉。在幻灯片中添加3-D效果形状,必然会为PPT的整体效果增色不少。为形状设置三维格式时,可设置棱台,轮廓线,表面效果等。
本篇文章,旨在介绍在使用免费的Spire.Presentation,独立创建Powerpoint文档,添加形状,并设置三维效果。感兴趣的朋友,可以从E-iceblue官网下载免费的Spire.Presentation。下载完成后,请将bin文件夹的.dll添加作为引用。友情提示:使用Spire.Presentation可独立创建powerpoint文档。
需要添加的命名空间:
步骤详叙:
步骤一:创建PPT文档。
步骤二:添加形状,设置其位置,大小并填充颜色。
步骤三:为该形状设置三维效果。
步骤四:再添加一个形状作为对照。
步骤五:保存文档为.pptx,启动查看效果。
效果截图:
完整代码:
本篇文章,旨在介绍在使用免费的Spire.Presentation,独立创建Powerpoint文档,添加形状,并设置三维效果。感兴趣的朋友,可以从E-iceblue官网下载免费的Spire.Presentation。下载完成后,请将bin文件夹的.dll添加作为引用。友情提示:使用Spire.Presentation可独立创建powerpoint文档。
需要添加的命名空间:
using Spire.Presentation; using Spire.Presentation.Drawing; using System.Drawing;
步骤详叙:
步骤一:创建PPT文档。
Presentation presentation = new Presentation();
步骤二:添加形状,设置其位置,大小并填充颜色。
IAutoShape shape1 = presentation.Slides[0].Shapes.AppendShape(ShapeType.RightArrow, new RectangleF(150, 150, 150, 150)); shape1.Fill.FillType = FillFormatType.Solid; shape1.Fill.SolidColor.KnownColor = KnownColors.RoyalBlue;
步骤三:为该形状设置三维效果。
ShapeThreeD Demo1 = shape1.ThreeD.ShapeThreeD; //设置表面效果 Demo1.PresetMaterial = PresetMaterialType.Matte; //设置棱台类型,高度和宽度 Demo1.TopBevel.PresetType = BevelPresetType.ArtDeco; Demo1.TopBevel.Height = 4; Demo1.TopBevel.Width = 12; //设置轮廓线类型,颜色,宽度 Demo1.BevelColorMode = BevelColorType.Contour; Demo1.ContourColor.KnownColor = KnownColors.LightBlue; Demo1.ContourWidth = 3.5;
步骤四:再添加一个形状作为对照。
IAutoShape shape2 = presentation.Slides[0].Shapes.AppendShape(ShapeType.Pentagon, new RectangleF(400, 150, 150, 150)); shape2.Fill.FillType = FillFormatType.Solid; shape2.Fill.SolidColor.KnownColor = KnownColors.LawnGreen; ShapeThreeD Demo2 = shape2.ThreeD.ShapeThreeD; Demo2.PresetMaterial = PresetMaterialType.SoftEdge; Demo2.TopBevel.PresetType = BevelPresetType.SoftRound; Demo2.TopBevel.Height = 12; Demo2.TopBevel.Width = 12; Demo2.BevelColorMode = BevelColorType.Contour; Demo2.ContourColor.KnownColor = KnownColors.LawnGreen; Demo2.ContourWidth = 5;
步骤五:保存文档为.pptx,启动查看效果。
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("result.pptx");
效果截图:
完整代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation; using Spire.Presentation.Drawing; using System.Drawing;
namespace test
{
class Program
{
static void Main(string[] args)
{
Presentation presentation = new Presentation();
IAutoShape shape1 = presentation.Slides[0].Shapes.AppendShape(ShapeType.RightArrow, new RectangleF(150, 150, 150, 150));
shape1.Fill.FillType = FillFormatType.Solid;
shape1.Fill.SolidColor.KnownColor = KnownColors.RoyalBlue;
ShapeThreeD Demo1 = shape1.ThreeD.ShapeThreeD;
Demo1.PresetMaterial = PresetMaterialType.Matte;
Demo1.TopBevel.PresetType = BevelPresetType.ArtDeco;
Demo1.TopBevel.Height = 4;
Demo1.TopBevel.Width = 12;
Demo1.BevelColorMode = BevelColorType.Contour;
Demo1.ContourColor.KnownColor = KnownColors.LightBlue;
Demo1.ContourWidth = 3.5;
IAutoShape shape2 = presentation.Slides[0].Shapes.AppendShape(ShapeType.Pentagon, new RectangleF(400, 150, 150, 150));
shape2.Fill.FillType = FillFormatType.Solid;
shape2.Fill.SolidColor.KnownColor = KnownColors.LawnGreen;
ShapeThreeD Demo2 = shape2.ThreeD.ShapeThreeD;
Demo2.PresetMaterial = PresetMaterialType.SoftEdge;
Demo2.TopBevel.PresetType = BevelPresetType.SoftRound;
Demo2.TopBevel.Height = 12;
Demo2.TopBevel.Width = 12;
Demo2.BevelColorMode = BevelColorType.Contour;
Demo2.ContourColor.KnownColor = KnownColors.LawnGreen;
Demo2.ContourWidth = 5;
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
}
}
}
相关文章推荐
- C#通过反射获取上层调用方法信息
- C# TreeView+checkBox 自动加载
- c# winform datagridview 编辑单元格内容,没有保存编辑内容
- C# WPF回显
- C#:序列化值与解码二进制
- C# Dev控件中的 PropertyGridControl 属性控件的基本用法以及排序
- C# 获取指定目录下所有文件信息、删除文件、目录,移动目录,拷贝目录
- Search for a Range C#
- C# 创建多级文件夹示例
- C# 将内容写入txt文档
- c# 扩展方法
- C# 之 FTP服务器中文件上传与下载(三)
- C#面向对象------单例模式
- C#获取QQ旋风的下载记录
- C#:写日志
- C#:只运行一个程序
- C#使用Dispose模式实现手动对资源的释放
- C#通过Semaphore类控制线程队列的方法
- 【C#】GC和析构函数(Finalize 方法)
- C#+OpenGL+FreeType显示3D文字(3) - 用PointSprite绘制文字