Now I have two questions here.
I am using the graphics object to create a customized report from a database. To ensure WYSIWIG, I use the same functions in the paint event of the panel with the printPage event of a PrintDocument after passing the necessary event arguments.
So far there is no trouble. Printing and previewing works just the way I want.
(NB - Did not use the printPreviewControl as I felt it was way slower than a panel. Don't know if I am right.)
So, Am I going the right way to create a WYSIWIG compliant application?
I want to save the created report into a XML format. I used the XMLWriter class, and was almost succesful in saving the report. I was ready to pat myself in the back and call it a day when it occured that I knew no way to serialize a Brush object. All I want to store is just the brush color. How can I get the color of a brush object? Because I don't see any properties exposed. Any workarounds?
As for the brush, figure out the type (likely a solid brush), cast it to that type, and serialize the properties you want.
e.g. (for a solid brush)
// brush is declared as Brush brush, but is a solid brush instanceif(brush is SolidBrush)
SolidBrush sb = (SolidBrush)brush;
// Serialize the properties of the brush here
elseif(brush is LinearGradientBrush)
// And so on and so forth.
// Repeat for other brush types as required