Free Support Forum - aspose.com

Rectangle background color problem

I generate a rectangle this way :

Rectangle rect = pres.Slides[0].Shapes.AddRectangle(50,50,1000,1000);
rect.FillFormat.Type = FillType.Pattern;
rect.FillFormat.BackColor = System.Drawing.Color.White;


It generates a rectangle with a green background color, there must be a problem with colors somewhere

thanks


Dear Stef,

You should define both colors (Fore and Back) for patterns.

I have done it

setting forecolor and backcolor doesn’t change the problem, the rectangle is still green

Dear Stef,

Please try this code:

Rectangle rect = pres.Slides[0].Shapes.AddRectangle(50,50,1000,1000);
rect.FillFormat.Type = FillType.Pattern;
rect.FillFormat.ForeColor = System.Drawing.Color.Blue;
rect.FillFormat.BackColor = System.Drawing.Color.White;

with your code the rectangle appears purple

Dear Stef,

It's not purple. It's a pattern with blue and white dots.

Rectangle rect = pres.Slides[0].Shapes.AddRectangle(50,50,1000,1000);
rect.FillFormat.Type = FillType.Pattern;
rect.FillFormat.ForeColor = System.Drawing.Color.Blue;
rect.FillFormat.BackColor = System.Drawing.Color.White;



Rectangle rect = pres.Slides[0].Shapes.AddRectangle(50,50,1000,1000);
rect.FillFormat.Type = FillType.Pattern;
rect.FillFormat.PatternStyle = PatternStyle.DiagonalBrick;
rect.FillFormat.ForeColor = System.Drawing.Color.Blue;
rect.FillFormat.BackColor = System.Drawing.Color.White;


how do I get a white rectangle ? (only white backcolor)

To make white rectangle you should set Solid fill type and White forecolor.

Rectangle rect = pres.Slides[0].Shapes.AddRectangle(50,50,1000,1000);
rect.FillFormat.Type = FillType.Solid;
rect.FillFormat.ForeColor = System.Drawing.Color.White;

Also I’d strogly recommend to read programmers guide. It has many examples of different fill styles:
http://www.aspose.com/Wiki/default.aspx/Aspose.PowerPoint/ShapeProperties.html