|
-
Mar 17th, 2009, 02:04 PM
#1
Thread Starter
New Member
Prevent Graphics Drawn in Panel from Refreshing
I'm making a plotting program. The panel (vs picturebox) is necessary because the data doesn't all fit into one screen so scrollbars are needed. I'm using graphics to draw the background layer and buttons for the data points.
When I scroll, the background is redrawn incorrectly since the top left corner of the panel is no longer the top left data point. Ideally, I'd like to prevent the background layer from redrawing entirely (after the initial draw). Alternatively, how do I take in consideration the new position of the scrolled panel in drawing the shapes & lines in the background layer?
Any general advice would be greatly appreciated!
-
Mar 17th, 2009, 02:07 PM
#2
Re: Prevent Graphics Drawn in Panel from Refreshing
Try to draw on a bitmap and assign it to the panel's background image instead of drawing directly on the panel.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Mar 17th, 2009, 05:28 PM
#3
Re: Prevent Graphics Drawn in Panel from Refreshing
Draw onto a bitmap, then get the scroll amount and draw the picture at position scrollamtpx * -1.
-
Mar 17th, 2009, 05:47 PM
#4
Lively Member
Re: Prevent Graphics Drawn in Panel from Refreshing
 Originally Posted by nblade
I'm making a plotting program. The panel (vs picturebox) is necessary because the data doesn't all fit into one screen so scrollbars are needed. I'm using graphics to draw the background layer and buttons for the data points.
When I scroll, the background is redrawn incorrectly since the top left corner of the panel is no longer the top left data point. Ideally, I'd like to prevent the background layer from redrawing entirely (after the initial draw). Alternatively, how do I take in consideration the new position of the scrolled panel in drawing the shapes & lines in the background layer?
Any general advice would be greatly appreciated!
google overriding the paint/draw properties of a picturebox... you may want to customize how/when its drawn and this will help...
-
Mar 18th, 2009, 01:56 PM
#5
Re: Prevent Graphics Drawn in Panel from Refreshing
I don't think that overriding the OnPaint would help, if that's what you mean. If you did and set it so that it will not send the normal message, it will be blank. Besides, you can't override a control's OnPaint without writing the code inside an object that inherits from control. Too much effort.
-
Mar 19th, 2009, 06:01 PM
#6
Thread Starter
New Member
Re: Prevent Graphics Drawn in Panel from Refreshing
Thanks all for your suggestions. I took stanav's advice and drew the background on to a bitmap. Then set the bitmap as the panel's background with the imagelayout.center setting.
-
Apr 16th, 2009, 06:32 PM
#7
Thread Starter
New Member
Re: Prevent Graphics Drawn in Panel from Refreshing
I've ran into a new problem with the solution above. If the size of the panel's content is increased (width & height are the same, the vertical & horizontal scrolls increase) at runtime, the background becomes messy. Panel.invalidate & panel.refresh under panelscroll event doesn't fix the background.
-
Apr 17th, 2009, 03:15 PM
#8
Re: Prevent Graphics Drawn in Panel from Refreshing
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
|