Finding A Point On The Form

  • Thread starter Thread starter sternr
  • Start date Start date
S

sternr

Hey,
I use the form's graphics object to draw points at random places on the
form.
After drawing the points, how can I know if a certain point on the form
is colored?
Thanks ahead

--sternr
 
sternr said:
Hey,
I use the form's graphics object to draw points at random places on the
form.
After drawing the points, how can I know if a certain point on the form
is colored?

... save the places (i.e. the x/y coordinates) that you have colored in a
list. If you keep the list sorted you can even use BinarySearch to
quickly find out if a certain coordinate is contained within the list.

hth,
Max
 
HI,

You can either save your points and check in this list or using the same
mechanism that you use to drawn you can query the points you just draw

Hint, you should definitely keep track of your points, if your form need
refresh you will have to re-draw them again.
 
Thanks for your replies!
The problem is, I draw lines and ellipses,
How can I know if a certain point is in one of them?
If I could get the point's color I could know to which line/polygon it
belongs...
Isnt there a way of doing it?

Thanks again!

--sternr
 
Hi,


How do you keep track of what you have drawn?
If the form is minimized and later restore you will have to redraw
everything.
 
Paul - thanks for the link - I'll use it!
But isn't there a way of recieving the actual point?

Ignacio - You'r right I'll have to take care of it, but is'nt there a
simpler way of doing it?
I mean it looks like I'm doing something wrong here...
Thanks again,

--sternr
 
sternr said:
Paul - thanks for the link - I'll use it!
But isn't there a way of recieving the actual point?

Ignacio - You'r right I'll have to take care of it, but is'nt there a
simpler way of doing it?
I mean it looks like I'm doing something wrong here...

You can use the Region class if you do not want to implement all the
math yourself. Using the Region class you can define (and draw/paint)
complex shapes. It also provides methods for figuring out if a certain
point is contained within a region. Have a look at:
bool Region.IsVisible(Point)
I think that should do what you want!

hth,
Max
 
Back
Top