|
-
January 12th, 2012, 10:34 AM
#1
DrawCurve on PictureBox - Disappears when resizing
I have a project I'm working on. I'm drawing a few curve on a PictureBoxs surface and whenever I resize or move the window the Curves disappear. I tried adding the points to List<Point> and on Form_Paint/Form_Resize (or anything else for that matter) it just "flashes by" a bit.
It only works when I click the button that says "Draw" and not in Form_Resize/Paint.
And I can't get the Graphics from my PictureBox because it's not there. The data is elsewhere, however the hell that can be. I can't save the data I've drawn to an Imagefile (JPG, PNG, whatever).
Here is my code:
Code:
private void buttonShowDiagram_Click(object sender, EventArgs e)
{
/* Here I calculate where the points are suppose to be in the Curves according to some data, which works very well... Not the rendering though. */
pictureCurve.CreateGraphics().Clear(Color.White);
/* DrawPoints is a List<> of List<> of Points to draw. DrawPens is a List of Pens. */
for (int i = 0; i < DrawPoints.Count; i++)
{
pictureCurve.CreateGraphics().DrawCurve(DrawPens[i], DrawPoints[i].ToArray());
}
}
If I then reuse this in "Form_Resize/Paint" it just flashes by, although adding a MessageBox there I know it executes everytime I Resize or something gets re-Painted.
Anyone know how I can either (or both) save the Graphics to a simple "IMAGE" so that after I've drawn it can Load the Image and show it? Or get it to "stay visible" all the time?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|