Graph Disappear Problem vol 2
-
I have returned with my "small" problem. Short overview: 1) Problem was/is that my graphics disappeared when you move them out of screen borders and pull them back or put some other window over them. 2) Graphics are updated every time I move my trackbar (which gives values to function to draw the graphic based on the values) So I've made some progress, but still stuck on other part. I have 3 different functions, one for graphic, second for graphic and third for axis. I solved the paint problem with Axis, since its static and never changes, so it was quite easy to convert to paint event. On the other hand, graphs have both 2 parameters that they receive and the graph changes after that according to the values given. Example : public void JoonistaGraafik(int k1, int k2) now when I want to make it to paint event "public void JoonistaGraafik(object sender,PaintEventArgs e, int k1, int k2)" I have problem calling out in InitializeComponents(); this.GraphPanel.Paint += new System.Windows.Forms.PaintEventHandler(JoonistaGraafik(slider_a, slider_b)); the thing is that, my two values "slider_a" and "slider_b" are generated in the trackbar_scroll event and then JoonistaGraafik(slider_a, slider_b); was called out. I'm pretty bad in explaining, but I hope that made a bit sence. In conclusion, the question is, how can I call out "this.GraphPanel.Paint += new System.Windows.Forms.PaintEventHandler(JoonistaGraafik(slider_a, slider_b));" if the slider_a and slider_b values have to change when I move the trackbar. Or how can I make a paint event which gets values from trackbars (means the graphic has to update itself every time trackbar is moved). Thanks for reading, and I hope someone can help me out (again).
-
I have returned with my "small" problem. Short overview: 1) Problem was/is that my graphics disappeared when you move them out of screen borders and pull them back or put some other window over them. 2) Graphics are updated every time I move my trackbar (which gives values to function to draw the graphic based on the values) So I've made some progress, but still stuck on other part. I have 3 different functions, one for graphic, second for graphic and third for axis. I solved the paint problem with Axis, since its static and never changes, so it was quite easy to convert to paint event. On the other hand, graphs have both 2 parameters that they receive and the graph changes after that according to the values given. Example : public void JoonistaGraafik(int k1, int k2) now when I want to make it to paint event "public void JoonistaGraafik(object sender,PaintEventArgs e, int k1, int k2)" I have problem calling out in InitializeComponents(); this.GraphPanel.Paint += new System.Windows.Forms.PaintEventHandler(JoonistaGraafik(slider_a, slider_b)); the thing is that, my two values "slider_a" and "slider_b" are generated in the trackbar_scroll event and then JoonistaGraafik(slider_a, slider_b); was called out. I'm pretty bad in explaining, but I hope that made a bit sence. In conclusion, the question is, how can I call out "this.GraphPanel.Paint += new System.Windows.Forms.PaintEventHandler(JoonistaGraafik(slider_a, slider_b));" if the slider_a and slider_b values have to change when I move the trackbar. Or how can I make a paint event which gets values from trackbars (means the graphic has to update itself every time trackbar is moved). Thanks for reading, and I hope someone can help me out (again).
StuffyEst wrote:
Subject: Graph Disappear Problem vol 2
I didn't knew, now questions come in volumes.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
StuffyEst wrote:
Subject: Graph Disappear Problem vol 2
I didn't knew, now questions come in volumes.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
I have returned with my "small" problem. Short overview: 1) Problem was/is that my graphics disappeared when you move them out of screen borders and pull them back or put some other window over them. 2) Graphics are updated every time I move my trackbar (which gives values to function to draw the graphic based on the values) So I've made some progress, but still stuck on other part. I have 3 different functions, one for graphic, second for graphic and third for axis. I solved the paint problem with Axis, since its static and never changes, so it was quite easy to convert to paint event. On the other hand, graphs have both 2 parameters that they receive and the graph changes after that according to the values given. Example : public void JoonistaGraafik(int k1, int k2) now when I want to make it to paint event "public void JoonistaGraafik(object sender,PaintEventArgs e, int k1, int k2)" I have problem calling out in InitializeComponents(); this.GraphPanel.Paint += new System.Windows.Forms.PaintEventHandler(JoonistaGraafik(slider_a, slider_b)); the thing is that, my two values "slider_a" and "slider_b" are generated in the trackbar_scroll event and then JoonistaGraafik(slider_a, slider_b); was called out. I'm pretty bad in explaining, but I hope that made a bit sence. In conclusion, the question is, how can I call out "this.GraphPanel.Paint += new System.Windows.Forms.PaintEventHandler(JoonistaGraafik(slider_a, slider_b));" if the slider_a and slider_b values have to change when I move the trackbar. Or how can I make a paint event which gets values from trackbars (means the graphic has to update itself every time trackbar is moved). Thanks for reading, and I hope someone can help me out (again).
Hi, I gave you all the necessary information 5 days ago[^], and I can tell you there is no way around doing it all in the Paint handler. You simply must, it is the only way to get it to paint whenever something needs repainted (as with uncovering part of your window when it has been covered by something else; as with resizing, minimizing and maximizing a window; as with printing which can reuse all the painting code; etc). In your specific situation, if you have two parameters that may change and cause your drawing to become invalid, what you do is: 1. store the drawing parameters that define your drawing as class members 2. draw everything (say on myPanel) in its Paint handler based on those parameters 3. and change those parameters where ever you feel you need to; and when you do change them, call myPanel.Invalidate() which will eventually result in myPanel.Paint() to be called automatically. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
Hi, I gave you all the necessary information 5 days ago[^], and I can tell you there is no way around doing it all in the Paint handler. You simply must, it is the only way to get it to paint whenever something needs repainted (as with uncovering part of your window when it has been covered by something else; as with resizing, minimizing and maximizing a window; as with printing which can reuse all the painting code; etc). In your specific situation, if you have two parameters that may change and cause your drawing to become invalid, what you do is: 1. store the drawing parameters that define your drawing as class members 2. draw everything (say on myPanel) in its Paint handler based on those parameters 3. and change those parameters where ever you feel you need to; and when you do change them, call myPanel.Invalidate() which will eventually result in myPanel.Paint() to be called automatically. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets