I have spent about a week figuring out how to do this and I finally have. To simulate an exclude path,
1. Make an XGraphicsPath
2. Add the shapes you want removed from the final shape. ex: Code:
clipPath.AddRectangle(temp.X , temp.Y , width , height)
* If these shapes are overlapping, this will not work as the overlaps will be filled in
** For paths/polygons, instead of adding paths to the clip path, you should:
a. call Code:
clipPath.StartFigure()
b. Add all of the lines from your path/polygon into the clip path. Code:
clipPath.AddLine(oldPoint, newPoint)
c. call Code:
clipPath.CloseFigure()
d. Do this for each path you have.
3. Add the final shape to the clip path. I have a big rectangle I'm cutting smaller rectangles out of, so now I'll add my large rectagle.
4. Set the clip path's fill mode to alternate. This is the even-odd fill that SVGs and other stuff has. Code:
clipPath.FillMode = XFillMode.Alternate
5. Call the intersect clip on your XGraphics object with this clip path. Code:
gfx.IntersectClip(clipPath)
6. Draw the final shape with your XGraphics object. This should be the same shape you added in step 3. Code:
gfx.DrawRectangle(xPen, xBrush, bigRect.X, bigRect.Y, bigWidth, bigHeight)
Now you will have your small shapes cut out of your large shape!
You can also call gfx.Save() before clipping and gfx.Restore() after drawing the final rectangle if you want.
I am 9 years late but hopefully this helps others.