InsertGroupShape

InsertGroupShape(params ShapeBase[])

Raggruppa le forme passate come parametro in un nuovo nodo GroupShape che viene inserito nella posizione corrente.

public GroupShape InsertGroupShape(params ShapeBase[] shapes)
ParametroTipoDescrizione
shapesShapeBase[]Elenco delle forme da raggruppare.

Osservazioni

La posizione e la dimensione del nuovo GroupShape verranno calcolate automaticamente.

Le forme VML e DML non possono essere raggruppate.

Esempi

Mostra come combinare la forma del gruppo con la forma.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape1 = builder.InsertShape(ShapeType.Rectangle, 200, 250);
shape1.Left = 20;
shape1.Top = 20;
shape1.Stroke.Color = Color.Red;

Shape shape2 = builder.InsertShape(ShapeType.Ellipse, 150, 200);
shape2.Left = 40;
shape2.Top = 50;
shape2.Stroke.Color = Color.Green;

// Combina le forme in un nodo GroupShape che viene inserito nella posizione specificata.
GroupShape groupShape1 = builder.InsertGroupShape(shape1, shape2);

// Combina i nodi Shape e GroupShape.
Shape shape3 = (Shape)shape1.Clone(true);
GroupShape groupShape2 = builder.InsertGroupShape(groupShape1, shape3);

doc.Save(ArtifactsDir + "Shape.CombineGroupShape.docx");

Mostra come inserire una forma di gruppo DML.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape1 = builder.InsertShape(ShapeType.Rectangle, 200, 250);
shape1.Left = 20;
shape1.Top = 20;
shape1.Stroke.Color = Color.Red;

Shape shape2 = builder.InsertShape(ShapeType.Ellipse, 150, 200);
shape2.Left = 40;
shape2.Top = 50;
shape2.Stroke.Color = Color.Green;

// Dimensioni per il nuovo nodo GroupShape.
double left = 10;
double top = 10;
double width = 200;
double height = 300;
// Inserisce il nodo GroupShape per la dimensione specificata, che viene inserito nella posizione specificata.
GroupShape groupShape1 = builder.InsertGroupShape(left, top, width, height, new Shape[] { shape1, shape2 });

// Inserisce il nodo GroupShape la cui posizione e dimensione verranno calcolate automaticamente.
Shape shape3 = (Shape)shape1.Clone(true);
GroupShape groupShape2 = builder.InsertGroupShape(shape3);

doc.Save(ArtifactsDir + "Shape.InsertGroupShape.docx");

Guarda anche


InsertGroupShape(double, double, double, double, params ShapeBase[])

Raggruppa le forme passate come parametro in un nuovo nodo GroupShape della dimensione specificata che viene inserito nella posizione specificata.

public GroupShape InsertGroupShape(double left, double top, double width, double height, 
    params ShapeBase[] shapes)
ParametroTipoDescrizione
leftDoubleDistanza in punti dall’origine al lato sinistro della forma del gruppo.
topDoubleDistanza in punti dall’origine al lato superiore della forma del gruppo.
widthDoubleLarghezza della forma del gruppo in punti. Non è consentito un valore negativo.
heightDoubleAltezza della forma del gruppo in punti. Non è consentito un valore negativo.
shapesShapeBase[]Elenco delle forme da raggruppare.

Osservazioni

Le forme VML e DML non possono essere raggruppate insieme.

Esempi

Mostra come inserire una forma di gruppo DML.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape1 = builder.InsertShape(ShapeType.Rectangle, 200, 250);
shape1.Left = 20;
shape1.Top = 20;
shape1.Stroke.Color = Color.Red;

Shape shape2 = builder.InsertShape(ShapeType.Ellipse, 150, 200);
shape2.Left = 40;
shape2.Top = 50;
shape2.Stroke.Color = Color.Green;

// Dimensioni per il nuovo nodo GroupShape.
double left = 10;
double top = 10;
double width = 200;
double height = 300;
// Inserisce il nodo GroupShape per la dimensione specificata, che viene inserito nella posizione specificata.
GroupShape groupShape1 = builder.InsertGroupShape(left, top, width, height, new Shape[] { shape1, shape2 });

// Inserisce il nodo GroupShape la cui posizione e dimensione verranno calcolate automaticamente.
Shape shape3 = (Shape)shape1.Clone(true);
GroupShape groupShape2 = builder.InsertGroupShape(shape3);

doc.Save(ArtifactsDir + "Shape.InsertGroupShape.docx");

Guarda anche