Grupa kształtów
Contents
[
Hide
]
Przykłady tworzenia grup kształtów, uzyskiwania do nich dostępu, rozgrupowywania oraz usuwania przy użyciu Aspose.Slides for .NET.
Dodaj grupę kształtów
Utwórz grupę zawierającą dwa podstawowe kształty.
static void AddGroupShape()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
var group = slide.Shapes.AddGroupShape();
group.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
group.Shapes.AddAutoShape(ShapeType.Ellipse, 60, 0, 50, 50);
}
Uzyskaj dostęp do grupy kształtów
Pobierz pierwszy grupowy kształt ze slajdu.
static void AccessGroupShape()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
var group = slide.Shapes.AddGroupShape();
group.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
var firstGroup = slide.Shapes.OfType<IGroupShape>().First();
}
Usuń grupowy kształt
Usuń grupowy kształt ze slajdu.
static void RemoveGroupShape()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
var group = slide.Shapes.AddGroupShape();
slide.Shapes.Remove(group);
}
Rozgrupuj kształty
Przenieś kształty poza kontener grupowy.
static void UngroupShapes()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
var group = slide.Shapes.AddGroupShape();
var rect = group.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, 50, 50);
// Przenieś kształt poza grupę.
slide.Shapes.AddClone(rect);
group.Shapes.Remove(rect);
}