FillFormat

Propriété Shape.FillFormat

Renvoie l’objet FillFormat qui contient les propriétés de formatage de remplissage pour une forme. Remarque : peut renvoyer null pour certains types de formes qui n’ont pas de propriétés de remplissage. Lecture seule IFillFormat.

public virtual IFillFormat FillFormat { get; }  

Exemples

L’exemple suivant montre comment changer la couleur d’accent pour un thème de présentation PowerPoint.

[C#]  
using (Presentation pres = new Presentation())  
{  
    IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100);  
    shape.FillFormat.FillType = FillType.Solid;  
    shape.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
}  

L’exemple suivant montre comment obtenir les couleurs de palette à partir de la couleur de thème principale puis les utiliser dans des formes.

[C#]  
using (Presentation presentation = new Presentation())  
{  
    ISlide slide = presentation.Slides[0];  
    // Accent 4  
    IShape shape1 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 50, 50);  
    shape1.FillFormat.FillType = FillType.Solid;  
    shape1.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
    // Accent 4, Plus clair 80%  
    IShape shape2 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 70, 50, 50);  
    shape2.FillFormat.FillType = FillType.Solid;  
    shape2.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
    shape2.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.MultiplyLuminance, 0.2f);  
    shape2.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.AddLuminance, 0.8f);  
    // Accent 4, Plus clair 60%  
    IShape shape3 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 130, 50, 50);  
    shape3.FillFormat.FillType = FillType.Solid;  
    shape3.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
    shape3.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.MultiplyLuminance, 0.4f);  
    shape3.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.AddLuminance, 0.6f);  
    // Accent 4, Plus clair 40%  
    IShape shape4 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 190, 50, 50);  
    shape4.FillFormat.FillType = FillType.Solid;  
    shape4.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
    shape4.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.MultiplyLuminance, 0.6f);  
    shape4.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.AddLuminance, 0.4f);  
    // Accent 4, Plus foncé 25%  
    IShape shape5 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 250, 50, 50);  
    shape5.FillFormat.FillType = FillType.Solid;  
    shape5.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
    shape5.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.MultiplyLuminance, 0.75f);  
    // Accent 4, Plus foncé 50%  
    IShape shape6 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 310, 50, 50);  
    shape6.FillFormat.FillType = FillType.Solid;  
    shape6.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent4;  
    shape6.FillFormat.SolidFillColor.ColorTransform.Add(ColorTransformOperation.MultiplyLuminance, 0.5f);  
    presentation.Save("example.pptx", SaveFormat.Pptx);  
}  

Voir aussi