PtInRegion

G

Guest

I wanted to use PtInRegion with some polygons to check which polygon a point
is in, however from what i can see, i need to set the polygons as regions
first, and this involves the GraphicsPath object which is in the compact
framework.

Does anyone have any ideas about doing this?
 
A

Alex Feinman [MVP]

Create a Region object, then keep calling Region.Union(Rectangle) until all
are joined into the region. Then use Region.IsVisible
If all you need is to find which of the multiple rectangles the point
belongs to, simply walk the list of rectacngles calling Rectangle.Contain(x,
y) on each
 
G

Guest

I assume that i can call Region.Union() with polygons?
Thanks for your help, but do i need a region per polygon, or just one for
all of them?

Chris
 
A

Alex Feinman [MVP]

Sorry, I was thinking rectangles although you clearly said "polygons". This
is somewhat more complicated. The problem is that Windows CE does not
support a concept of polygonal region. For this reason Compact Framework
does not have equivalent methods. When you look under the hood of
non-rectangular regions in full Windows, they are built from a large amount
of rectangles. I've written code like that at some point to create complex
regions used by SetWindowRegion from a bitmap containing a mask. I would
scan a bitmap line, by line and build a 1px tall rectangle, then append it
to the existing region. In your case it would be harder since you don't even
have a bitmap
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top