Cannot go back to old clip region

  • Thread starter Thread starter Reiner Obrecht
  • Start date Start date
R

Reiner Obrecht

I save my old cliping region and do some work with a new clipping region.
When I want to switch back I get another clipping region contents in my
Graphics object than before. The saved region in "oldClip" is still correct.

Region oldClip = g.Clip;
g.Clip = new Region(path); // new region is perfect

// several drawings which are correct ....

g.Clip = oldClip; // it happens here

Has anyone an idea, where the problem can come from? Thanks for helping.
 
I save my old cliping region and do some work with a new clipping region.
When I want to switch back I get another clipping region contents in my
Graphics object than before. The saved region in "oldClip" is still
correct.

How do you know the saved region is "still correct"?
Region oldClip = g.Clip;
g.Clip = new Region(path); // new region is perfect

// several drawings which are correct ....

g.Clip = oldClip; // it happens here

Has anyone an idea, where the problem can come from? Thanks for helping.

Not really. Everything looks good at first glance, but then I use the
SetClip() method and not the Clip property when dealing with clipping
regions, so I can't say I have any experience with cases like yours. (Not to
mention that I haven't yet had a need to save an existing clipping region.)

How about cloning? Make the first line

Region oldClip = (Region)g.Clip.Clone();
 
Jeff Johnson said:
Not really. Everything looks good at first glance, but then I use the
SetClip() method and not the Clip property when dealing with clipping
regions, so I can't say I have any experience with cases like yours. (Not
to mention that I haven't yet had a need to save an existing clipping
region.)

Setting the 'Clip' property will cause the following call: 'Me.SetClip(<new
value>, CombineMode.Replace)'.
 
Back
Top