Shapes

Collect.Shapes method

收集Shape中的所有实例Presentation.

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

返回值

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

例子

using (Presentation pres = new Presentation("pres.pptx"))
{
    foreach (Shape shape in Collect.Shapes(pres))
    {
         // 如果形状是自选图形,添加黑色实心边框
        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);
}        

也可以看看