群組圖形
Contents
[
Hide
]
使用 Aspose.Slides for C++ 建立圖形群組、存取、取消群組及移除的範例。
新增群組圖形
建立一個包含兩個基本圖形的群組。
static void AddGroupShape()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto group = slide->get_Shapes()->AddGroupShape();
group->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 0, 0, 50, 50);
group->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 60, 0, 50, 50);
presentation->Dispose();
}
存取群組圖形
從投影片中取得第一個群組圖形。
static void AccessGroupShape()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto group = slide->get_Shapes()->AddGroupShape();
group->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 0, 0, 50, 50);
auto firstGroup = SharedPtr<IGroupShape>();
for (auto&& shape : slide->get_Shapes())
{
if (ObjectExt::Is<IGroupShape>(shape))
{
firstGroup = ExplicitCast<IGroupShape>(shape);
break;
}
}
presentation->Dispose();
}
移除群組圖形
從投影片中刪除群組圖形。
static void RemoveGroupShape()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto group = slide->get_Shapes()->AddGroupShape();
slide->get_Shapes()->Remove(group);
presentation->Dispose();
}
取消圖形群組
將圖形從群組容器中移出。
static void UngroupShapes()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto group = slide->get_Shapes()->AddGroupShape();
auto rect = group->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 0, 0, 50, 50);
// 將圖形移出群組。
slide->get_Shapes()->AddClone(rect);
group->get_Shapes()->Remove(rect);
presentation->Dispose();
}