473,810 Members | 3,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing xor lines

In my opinion, one of the worst failures of Net (VB2005 Pro) was not
providing an XOR line draw feature, as in VB6.

A major feature of my app is allowing the user to draw Markers (vertical
lines) on a trace so they can measure the time difference between markers.

Once they click on a desired location, on a trace, arrow buttons are
provided so they can move the marker to an exact location. With xor, I just
redraw the current marker to make it disappear then draw a new marker one
pixel away. No sweat in VB6.

I have put a screen shot of a typical trace with markers on my web site
under "Private" then click on "Marker display" "screen shot"
http://home.surewest.net/galen/index.html

I would appreciate any guidance I can get.

The traces are on a bitmap which is contained in a User Control. I thought
of drawing the marker on a copy of the bitmap. To move the marker I would
toss the copy and draw the new marker on a new copy of the original bitmap.
This, of course, would complicate my User Control.

Also there can be up to four markers displayed. If I move one and toss the
bitmap copy, I not only have to draw the new marker but I have to redraw the
other three which didn't move.

As you can see on the screen shot, a marker also shows some text (time
difference between markers). This means I can't just read in a vertical set
of pixels and later restore them as the marker is moved.

I could read a vertical rectangle which would be as wide as the worst case
text size.

Also, as the marker nears the right edge of the screen, the text is placed
to the left of the marker.

H E L P

GalenS
Apr 5 '06 #1
11 4374
DrawReversibleF rame()
Apr 5 '06 #2
it's there, just called something different, Galen already stated it, it's
been there since .NET 1.0
"Galen Somerville" <ga***@communit y.nospam> wrote in message
news:eA******** ******@TK2MSFTN GP05.phx.gbl...
In my opinion, one of the worst failures of Net (VB2005 Pro) was not
providing an XOR line draw feature, as in VB6.

A major feature of my app is allowing the user to draw Markers (vertical
lines) on a trace so they can measure the time difference between markers.

Once they click on a desired location, on a trace, arrow buttons are
provided so they can move the marker to an exact location. With xor, I
just redraw the current marker to make it disappear then draw a new marker
one pixel away. No sweat in VB6.

I have put a screen shot of a typical trace with markers on my web site
under "Private" then click on "Marker display" "screen shot"
http://home.surewest.net/galen/index.html

I would appreciate any guidance I can get.

The traces are on a bitmap which is contained in a User Control. I thought
of drawing the marker on a copy of the bitmap. To move the marker I would
toss the copy and draw the new marker on a new copy of the original
bitmap. This, of course, would complicate my User Control.

Also there can be up to four markers displayed. If I move one and toss the
bitmap copy, I not only have to draw the new marker but I have to redraw
the other three which didn't move.

As you can see on the screen shot, a marker also shows some text (time
difference between markers). This means I can't just read in a vertical
set of pixels and later restore them as the marker is moved.

I could read a vertical rectangle which would be as wide as the worst case
text size.

Also, as the marker nears the right edge of the screen, the text is placed
to the left of the marker.

H E L P

GalenS

Apr 5 '06 #3

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
DrawReversibleF rame()


That would be a real kludge. DrawReversibleL ine 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.

GalenS
Apr 5 '06 #4
"Galen Somerville" <ga***@communit y.nospam> schrieb:
DrawReversibleF rame()


That would be a real kludge. DrawReversibleL ine 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.


Unfortunately this is a limitation of GDI+ which 'System.Drawing ' is based
on.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 5 '06 #5

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:OF******** ******@TK2MSFTN GP05.phx.gbl...
"Galen Somerville" <ga***@communit y.nospam> schrieb:
DrawReversibleF rame()


That would be a real kludge. DrawReversibleL ine 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.


Unfortunately this is a limitation of GDI+ which 'System.Drawing ' is based
on.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

I was hoping you wouldn't say that.

Looks like I have build up a class to replace a one-liner in VB6

GalenS
Apr 5 '06 #6
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.MakeT ransparent(Colo r.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.

Apr 5 '06 #7

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:27******** *************** ***********@mic rosoft.com...
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.MakeT ransparent(Colo r.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.


That would work. My user control has a "permanent" bitmap (Bmp) which I
believe is continually painted by

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e)
e.Graphics.Draw Image(Bmp, e.ClipRectangle , e.ClipRectangle ,
GraphicsUnit.Pi xel)
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.

The user, of the app, has 12 default colors that can be changed to suit
them. This includes back and fore colors, marker color, trace1/2/3 etc
colors.

Question. To paint the bmOverlay would I just set a flag then have an If
statement in the above OnPaint event?

GalenS
Apr 6 '06 #8
> My user control has a "permanent" bitmap (Bmp) which I
believe is continually painted by

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e)
e.Graphics.Draw Image(Bmp, e.ClipRectangle , e.ClipRectangle ,
GraphicsUnit.Pi xel)
End Sub
"Continuall y" 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? "Continuall y" kind of throws
me.
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.
Still thrown by continually and now permanent above.
Question. To paint the bmOverlay would I just set a flag then have an If
statement in the above OnPaint event?


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.Invalidat e(), and painting took place as follows:

Private Sub Form1_Paint(ByV al sender As Object, ByVal e As PaintEventArgs) _
Handles MyBase.Paint
e.Graphics.Draw Image(bmImage, 0, 0)
e.Graphics.Draw Image(bmOverlay , 0, 0)
End Sub

I don't think this difference is of consequence.
Apr 6 '06 #9

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:65******** *************** ***********@mic rosoft.com...
My user control has a "permanent" bitmap (Bmp) which I
believe is continually painted by

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e)
e.Graphics.Draw Image(Bmp, e.ClipRectangle , e.ClipRectangle ,
GraphicsUnit.Pi xel)
End Sub


"Continuall y" 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? "Continuall y" kind of
throws
me.
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.


Still thrown by continually and now permanent above.
Question. To paint the bmOverlay would I just set a flag then have an If
statement in the above OnPaint event?


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.Invalidat e(), and painting took place as follows:

Private Sub Form1_Paint(ByV al sender As Object, ByVal e As
PaintEventArgs) _
Handles MyBase.Paint
e.Graphics.Draw Image(bmImage, 0, 0)
e.Graphics.Draw Image(bmOverlay , 0, 0)
End Sub

I don't think this difference is of consequence.


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


Apr 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1609
by: Michael Kalina | last post by:
Hi! I have a problem with my CSS and Mozilla Firefox as well as Opera 7.xx: On my homepage http://michaelsremarks.com, I use a BlogRoll. When the page loads, there is a break of all the lines in exactly the height of the BlogRoll, which seems to load it's content after the drawing of the lines. How can I avoid this error? (Or does it has to do with CSS anyway?)
8
22440
by: john | last post by:
Hi I am a C++ newbie, I am looking to draw single lines and simple boxes in a C++ console window. Is there a draw command with x and y coordinates that can be used with my Dev C++ compiler. For simplicity sake, I would be prepared to draw using characters such as _ or * if proper line drawing is really complicated. Thanks in advance. Walt
10
2331
by: Zach | last post by:
In an invoicing program I draw lines in a text file using: new string ("-",73) new string ("=",73) These lines look awful. Is there a better way? Much obliged.
6
1398
by: K.N.Ranjit | last post by:
Here's my coding again: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents and Settings\rvish\Desktop\trverse.mdb;Persist Security Info=False") rs.Open("select Easting,Northing,UserID from trverse order by cint(UserID)", cn,
5
2378
by: Manuel Daponte | last post by:
I found this code in this newsgroup and used it, but the lines drawn are composed of point too separated when the mouse moves at medium or fast speed. How can I fix it? Thanks in advance !!! Dim bTracking As Boolean Dim blackPen As Pen Dim g As Graphics
9
3191
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
0
1195
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
I have a form that I'm drawing some lines on using the DrawLines method. It all works fine as long as I don't try to draw these lines inside a group box. When I do, however, the lines don't show. I've tried sending the GroupBox to the back, but it makes no difference. It seems that I somehow need to be able to specify that the lines be drawn on the front, or be able to send them to the front after they are drawn. How can I do this? ...
4
3787
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've windows form, in this form i've a panel. I want to draw lines inside the panel using the panel coordinates( meaing that the left upper corner of the panel is 0,0), how can i do it? Thanks, Gidi.
0
1138
by: BarryM | last post by:
Iv got a panel on the main form which is set to auto scroll. In the panel there is a picture box that i draw lines in. the lines work perfectly fine until the scroll bar comes up. The picture box expands in the scrollable panel but the program wont allow the lines to continuing drawing(vb 2005) here's the coding Public Class Form1 Dim DrawGraphics As Graphics Dim DrawBitmap As Bitmap Dim y2 As Integer
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.