containment of a rectangle in an irregular region

P

PJ6

I've Googled this but come up short... I have a non-rectangular region that
contains a moveable rectangle. I want to restrict the rectangle's movement
to have it always fully contained in this region. Would seem pretty simple
to do this with a region's IsVisible function, but no, IsVisible returns
true if any portion of the rectangle is visible.

I know I'll eventually get this just by messing around but don't want to
unnecesssarily re-invent the wheel... is there something built into the
Framework that I can use?

Paul
 
P

PJ6

Sometimes I think I post just because Murphy's Law dictates that I must then
find the solution myself sortly thereafter...

Private Function DoesPathFullyContain( _
ByVal p As GraphicsPath, ByVal rect As Rectangle) As Boolean
Dim ret As Boolean
Dim r1 As New Region(p)
Dim r2 As New Region
r2.MakeInfinite()
r2.Exclude(r1)
ret = Not r2.IsVisible(rect)
Return ret
End Function
 
Top