Shapes

Collect.Shapes 方法

收集 Presentation 中所有的 Shape 实例。

public static IEnumerable<Shape> Shapes(Presentation pres)
参数类型描述
presPresentation用于收集形状的演示文稿

返回值

演示文稿中包含的所有形状的集合

示例

using (Presentation pres = new Presentation("pres.pptx"))
{
    foreach (Shape shape in Collect.Shapes(pres))
    {
        // 如果形状是 AutoShape,则添加黑色实线边框
        if (shape is AutoShape autoShape)
        {
            autoShape.LineFormat.Style = LineStyle.Single;
            autoShape.LineFormat.Width = 10f;
            autoShape.LineFormat.FillFormat.FillType = FillType.Solid;
            autoShape.LineFormat.FillFormat.SolidFillColor.Color = Color.Black;
        }
    }
    
    pres.Save("pres-out.pptx", SaveFormat.Pptx);
}        

另请参阅