K
Keith Rebello
I have almost written a class to draw some vectors on either a PictureBox or
to a PrintDocument. Besides all the properties, the class has one method
named Draw.
In my class constructors, I send either a PictureBox or a PrintDocument and
get all the properties of the drawing surface to size my graphics.
The problem is that to actually draw the vectors, I need to have a Graphics
object which is obtained from either the "e as PaintEventArgs" in the
PictureBox_Paint event or "e as PrintPageEventArgs" in the PrintPage event
of the PrintDocument control.
This forces the user of my class to call the Draw method in either the Paint
or PrintPage events.
Is there a way to obtain the Graphics object from anywhere in code? Ideally
I would like to be able to obtain the Graphics object in either the
constructor or in the Draw method. Does this have something to do with
raising events? If so, how does one achieve this?
Any help would be greatly appreciated.
to a PrintDocument. Besides all the properties, the class has one method
named Draw.
In my class constructors, I send either a PictureBox or a PrintDocument and
get all the properties of the drawing surface to size my graphics.
The problem is that to actually draw the vectors, I need to have a Graphics
object which is obtained from either the "e as PaintEventArgs" in the
PictureBox_Paint event or "e as PrintPageEventArgs" in the PrintPage event
of the PrintDocument control.
This forces the user of my class to call the Draw method in either the Paint
or PrintPage events.
Is there a way to obtain the Graphics object from anywhere in code? Ideally
I would like to be able to obtain the Graphics object in either the
constructor or in the Draw method. Does this have something to do with
raising events? If so, how does one achieve this?
Any help would be greatly appreciated.