Open CsoftTarun opened 4 years ago
I use XColor to recreate the whole Brush
SolidColorBrush solidbrush = mybrush as SolidColorBrush;
XBrush xbrush = new XSolidBrush(XColor.FromArgb(solidbrush.Color.A,solidbrush.Color.R,solidbrush.Color.G,solidbrush.Color.B));
same applies for the XPen, also keep in mind that SolidBrush and Brush aren't exactly the same, when we use Solid that means that our brush is based on a Color, in the other hand a Brush or a Pen can base on an Image, you can draw shapes and fill them with an image as a Foreground(Stroke) or Background(Fill), and not just a color.
Getting this error for XBrush, XImage, XPen while casting.
public void DrawRectangle(Pen pen, Brush brush, double X, double Y, double W, double H) { XPen penUsed = pen != null ? new XPen(XColor.FromName(pen.Color.Name), pen.Width) : null; XBrush brushUsed = (XBrush)brush; gfx.DrawRectangle(penUsed, brushUsed, X, Y, W, H); }
How to get solve this error?