I have region:

Region r

and I have a point:

PointF p

is there any method that determines whether p is in r?
something like this

bool is_p_in_r = graphics.Determine(p,r);
if(is_p_in_r)
       Execute("theMan.kil");
:)

Recommended Answers

All 5 Replies

Can you use RectangleF rf = r.GetBounds(graphics); then if(rf.Contains(p)) do whatever? I'm assuming that graphics is of type Graphics and is initialized somehow.

Can you use RectangleF rf = r.GetBounds(graphics); then if(rf.Contains(p)) do whatever?

well .. if the region is circular then there may be points in rf that are not in the region! in other words rf is a superset of the region!

I gotcha. I had that possibility in the back of my mind but I wasn't sure how the regions were defined. Apologies.

There's also the intersect method of the region itself. It requires a rectangle but send your point in as a 1 pixel by 1 pixel rectangle. If the intersection is empty you'll know the point is not there (looks like you need to save a copy of your region first since it will clobber it with the result when you call the method). I don't think that makes any assumptions about the shape of the region.

There's also the intersect method of the region itself. It requires a rectangle but send your point in as a 1 pixel by 1 pixel rectangle. If the intersection is empty you'll know the point is not there (looks like you need to save a copy of your region first since it will clobber it with the result when you call the method). I don't think that makes any assumptions about the shape of the region.

thanks. I think it works... it's like a mathematical trick ..
I was going to code it but.. accidentally I found the polymorphic method isVisible ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.