Graphics front-back

2499
3
Jump to solution
04-30-2012 11:52 AM
LuisGarcia2
Occasional Contributor II
I have a graphics layer where I add several graphics. Some times the graphics are very close and there are some I would like to bring to the front so the client can have a better view of them. Is there any way to do that programmatically? I did not see anything in the API.
Thanks!
0 Kudos
1 Solution

Accepted Solutions
LuisGarcia2
Occasional Contributor II
Never mind. I think I got it. What I did was to set the Z-index to 0 in all the graphics I have when I instantiate them to make sure they are all at the lowest level. When I need to show them on top of the others I set the z-index to a high number and they show the way I want. I can re-set them to zero if I want them back at the level they were first.
Thanks for your help!

View solution in original post

0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
You can probably check collision by using Extent.Intersects() and setting Graphic.SetZIndex(index) or stack order of the graphic in the collection.
0 Kudos
LuisGarcia2
Occasional Contributor II
Jennifer,
thanks for your reply. I tried the z order which I thought was a the fastest procedure and did not get good results. Not sure why. I got the count of graphics that I had at the specific moment in the  layer so it would be the highest number possible and set the z index with that and still they were overlapping. I also tried using this:


Graphics.Move(Graphics.IndexOf(myGraphic), 0);


That does the trick when I do one by one; but if I do several at the same time the graphics disappear from the screen for an instance. That tells me that likely the "move" algorithm is more time consuming (and I think that make sense).
So, any advice with the z-index? Is that the right way to use it? I'd like to use that approach if possible so the graphics don't flicker like that.

Thanks!
0 Kudos
LuisGarcia2
Occasional Contributor II
Never mind. I think I got it. What I did was to set the Z-index to 0 in all the graphics I have when I instantiate them to make sure they are all at the lowest level. When I need to show them on top of the others I set the z-index to a high number and they show the way I want. I can re-set them to zero if I want them back at the level they were first.
Thanks for your help!

View solution in original post

0 Kudos