draw lines in the picturebox that appear and disappear with a certain frequency

Viewed 46

/fcnPtr - refers to the function/

I have a button click event handler that draws in a picturebox.(first I draw a graph of the function, then the projections I need) I draw two projections first.(red pen) then, I want to draw the next two projections, but I want them to be displayed, for example, after 5 seconds(like an analog of sleep()), as the previous ones will be displayed. at the same time, so that those that were drawn with a red pen disappear.And then that they were both disappearing.and then it all started over again.that is, so that it is cyclical.

I tried to draw what I mean, what I want to get. enter image description here

Please tell me how I can do this?I will be very grateful for your help.

 int unit = 35;
 int pW = pictureBox1->Width;
 int pH = pictureBox1->Height;

 Bitmap^ img = gcnew Bitmap(pW, pH); 

 Graphics^ g = Graphics::FromImage(img);

. . .

 float projection_y = fcnPtr(_a) * (double)unit;
 float projection_x = _a * (double)unit;
 g->DrawLine(Pens::Red, projection_x, 0.0, projection_x, projection_y);
 float projection_y_b = fcnPtr(_b) * (double)unit;
 float projection_x_b = _b * (double)unit;
 g->DrawLine(Pens::Red, projection_x_b, 0.0, projection_x_b, projection_y_b);
 Sleep(5);//I know, that it doesn't fit here. I just wrote what I mean
 float projection_a_y1 = fcnPtr(points_a[0]) * (double)unit;
 float projection_a_x1 = points_a[0] * (double)unit;
 g->DrawLine(Pens::Blue, projection_a_x1, 0.0, projection_a_x1, projection_a_y1);
 float projection_b_y1 = fcnPtr(points_b[0]) * (double)unit;
 float projection_b_x1 = points_b[0] * (double)unit;
 g->DrawLine(Pens::Blue, projection_b_x1, 0.0, projection_b_x1, projection_b_y1);


 delete g; 

 this->pictureBox1->Image = img; 
0 Answers
Related