PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

DrawRectange not filling in with color
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4361
Page 1 of 1

Author:  jon.farmer [ Tue Aug 09, 2022 12:26 pm ]
Post subject:  DrawRectange not filling in with color

I am attempting to draw a filled rectangle on the document.

If I do this the rectangle is filled in

Code:
 XRect tableHeader = new XRect(20, 250, 550, 15);
            gfx.DrawRectangle(XPens.LightBlue, XBrushes.LightBlue, tableHeader);


If I do this the outline of the rectangle is only shown.

Code:
         XRect tableHeader = new XRect(20, 250, 550, 15);
            XBrush tableHeaderBackground = new XSolidBrush(new XColor { R = 222, G = 234, B = 246});
            gfx.DrawRectangle(XPens.LightBlue, tableHeaderBackground, tableHeader);


What am I missing here?

TIA

Author:  TH-Soft [ Tue Aug 09, 2022 9:11 pm ]
Post subject:  Re: DrawRectange not filling in with color

Congratulations, you created a brush that is 100% transparent.

Use this code to create a transparency of 50%:
Code:
XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));


Use this code to create a transparency of 0%:
Code:
XBrush brush = new XSolidBrush(XColor.FromArgb(255, 0, 0));

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/