ShapeType
Contenu
[
Cacher
]ShapeBase.ShapeType property
Obtient le type de forme.
public ShapeType ShapeType { get; }
Exemples
Montre comment créer un groupe de formes et imprimer son contenu à l’aide d’un visiteur de document.
public void GroupOfShapes()
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Si vous devez créer des formes "NonPrimitive", telles que SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, DiagonalCornersRounded
// veuillez utiliser les méthodes DocumentBuilder.InsertShape.
Shape balloon = new Shape(doc, ShapeType.Balloon)
{
Width = 200,
Height = 200,
Stroke = { Color = Color.Red }
};
Shape cube = new Shape(doc, ShapeType.Cube)
{
Width = 100,
Height = 100,
Stroke = { Color = Color.Blue }
};
GroupShape group = new GroupShape(doc);
group.AppendChild(balloon);
group.AppendChild(cube);
Assert.True(group.IsGroup);
builder.InsertNode(group);
ShapeGroupPrinter printer = new ShapeGroupPrinter();
group.Accept(printer);
Console.WriteLine(printer.GetText());
}
/// <summary>
/// Imprime le contenu d'un groupe de formes visité sur la console.
/// </summary>
public class ShapeGroupPrinter : DocumentVisitor
{
public ShapeGroupPrinter()
{
mBuilder = new StringBuilder();
}
public string GetText()
{
return mBuilder.ToString();
}
public override VisitorAction VisitGroupShapeStart(GroupShape groupShape)
{
mBuilder.AppendLine("Shape group started:");
return VisitorAction.Continue;
}
public override VisitorAction VisitGroupShapeEnd(GroupShape groupShape)
{
mBuilder.AppendLine("End of shape group");
return VisitorAction.Continue;
}
public override VisitorAction VisitShapeStart(Shape shape)
{
mBuilder.AppendLine("\tShape - " + shape.ShapeType + ":");
mBuilder.AppendLine("\t\tWidth: " + shape.Width);
mBuilder.AppendLine("\t\tHeight: " + shape.Height);
mBuilder.AppendLine("\t\tStroke color: " + shape.Stroke.Color);
mBuilder.AppendLine("\t\tFill color: " + shape.Fill.ForeColor);
return VisitorAction.Continue;
}
public override VisitorAction VisitShapeEnd(Shape shape)
{
mBuilder.AppendLine("\tEnd of shape");
return VisitorAction.Continue;
}
private readonly StringBuilder mBuilder;
}
Voir également
- enum ShapeType
- class ShapeBase
- espace de noms Aspose.Words.Drawing
- Assemblée Aspose.Words