OpennetCF GraphicsEx, the PictureBox and System.drawing.graphics- A compact framework question

S

surjones

I have picturebox, on which I need to paint complex graphics, and
therefore I used the GraphicsEx class and associated penX class over a
pictureBox control
(GraphicsEx.fromControl(System.windows.controls.control).

Also, I need some methods of System.drawing.graphics class (which are
not in GraphicsEx). So I called Graphics.FromImage(Picturebox.Image).
Like this:
(where pb1 is a pictureBox control on the Main Form)

GraphicsEx gX=GraphicsEx.FromControl(pb1);

//create an image for this pb1 as big as the form
pb1.Image=new Bitmap(this.Width, this.Height);

Graphics g2=Graphics.FromImage(pb1.Image);

g2.Clear(Color.White);

gX.DrawLine(new PenEx (System.Drawing.Color.Red,5),0,0,200,200);

g2.DrawLine(new Pen(Color.Blue),0,0,200,200);

Now what happens is that the "fat red" line made by gX appears
momentariliy but after that g2's blue thin line prevails..

I think this is being caused becuase gX uses GDI+ internally and does
not paint on the "image of the picture box", but straight on the DC of
the pictureBox control. Is there any way I can get the gX's painting to
be done on the image?

Hope this was not confusing!
Thanks in advance
Suraj
 
Top