G
Guest
DrawReversibleFrame()
AMercer said:DrawReversibleFrame()
Galen Somerville said:That would be a real kludge. DrawReversibleLine would do for the actual
marker line.
But what about the text? Also the user now has the ability to use a
specific color for the markers.
I was hoping you wouldn't say that.Herfried K. Wagner said:Unfortunately this is a limitation of GDI+ which 'System.Drawing' is based
on.
AMercer said:how about this. have the fixed trace be one bitmap drawn first and have a
changing overlay bitmap that has a transparent background drawn on top of
the
trace.
make a bitmap (bmOverlay) of the same size as the fixed drawing (the
trace).
Make this bitmap transparent for black via
bmOverlay.MakeTransparent(Color.Black)
when an update happens, clear the bmOverlay to black, rebuild all its
vertical lines and text as you wish (location, color, etc). When it is
time
to paint, paint the fixed bitmap first, then bmOverlay.
believe is continually painted by
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.DrawImage(Bmp, e.ClipRectangle, e.ClipRectangle,
GraphicsUnit.Pixel)
End Sub
When I want to clear the bitmap I use the BackColor property. The first use
of this property sets up the permanent bitmap and sets a flag. Subsequent
calls see the flag and skip the setup and just clears the bitmap to the
proper color.
Question. To paint the bmOverlay would I just set a flag then have an If
statement in the above OnPaint event?
AMercer said:"Continually" painted? Do you mean that the trace bitmap needs repainting
because it is being updated, maybe moving horizontally as time passes? If
so, don't you want the overlay to move with it? "Continually" kind of
throws
me.
Still thrown by continually and now permanent above.
I ran one test, and painting (via DrawImage) the overlay bitmap after the
trace bitmap works fine. A flag that governs whether the overlay is
visible
or not sounds like a good idea to me. Just to be complete, my test
program
did not use OnPaint. Instead, when it had an updated bitmap it did
Form1.Invalidate(), and painting took place as follows:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
PaintEventArgs) _
Handles MyBase.Paint
e.Graphics.DrawImage(bmImage, 0, 0)
e.Graphics.DrawImage(bmOverlay, 0, 0)
End Sub
I don't think this difference is of consequence.
Oops, I use Me.InvalidateGalen Somerville said:Yes it is rather confusing. The trace display is Heart sounds and is an
oscilloscope type of display. That is, every few seconds lines are drawn
to connect the next 4 pixels horizontally. Since we show a gap, typically
5 to 10 pixels wide, we have to also have to redraw the existing 4 pixels
beyond the gap to the background color.
Originally I was getting flickering and other display problems. In a
stroke of genious, I added a module to the usercontrol and moved certain
declarations to this module as Public. Specifically g as Graphics, p as
Pen, f as Font and Bmp as bitmap. This is what I meant by "permanent".
Now the display is as solid as a rock. Continually is probably the wrong
wording. I don't make a change an then invalidate. I just make the
changes. As I understand it, invalidate means do a Paint on next vertical
sweep. I further understand that the overides OnPaint means Paint on every
vertical sweep.
GalenS