views:

56

answers:

1

I am still simulating a radar (or attempting to) and through trial and error managed to draw a pie on top of my picturebox's background the more or less covers the target area I wish to draw to. Now I'm trying to make that area my clipping region. How do I achieve this? I haven't come across anything that explains this clearly. I have the following code:

void OnPaintRadar(Object sender, PaintEventArgs e)
{
    Graphics g = e.Graphics;
    Rectangle radar_rect = new Rectangle(myRadarBox.Left + 90, myRadarBox.Left + 18, myRadarBox.Width - 200, myRadarBox.Height + 200);
    using (Pen drw_pen = new Pen(Color.White, 1) )
    {
        g.DrawPie(drw_pen,radar_rect, 180, 180);
    }
}

what I want to do now is make th pie I've just drawn my clipping area.

+1  A: 

You can't use the pie you've drawn on the Graphics, you need to define it separately for the region :

GraphicsPath gpath new GraphicsPath();
gpath.AddPie(rect, startAngle, sweepAngle);
gpath.CloseFigure();
this.Region = new Region(gpath);
Thomas Levesque
Thanks very much
Dark Star1
I still have a problem adding my image to the region. I have a tiny pic with I use to depict an object; using g.DrawImage fills the entire region with the pic which isn'tthe result I wanted and g.DrawImageUnscaled shows nothing.
Dark Star1